Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

apache - configuring virtual host and localhost redirecting to the xampp folder

I have problem with creating virtual host. I am using Windows 7 x64 Professional. In file C:WindowsSystem32driversetchosts I have only this lines:

127.0.0.1   myhost
127.0.0.1   www.myhost

And in file C:xamppapacheconfextrahttpd-vhosts.conf I have this:

NameVirtualHost *:80
<VirtualHost *:80> 
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost
    ServerAlias www.localhost
</VirtualHost>

<VirtualHost *:80> 
    DocumentRoot "C:/Users/Me/Dropbox/Project/public"
    ServerName myhost
    ServerAlias www.myhost
    <Directory "C:/Users/Me/Dropbox/Project/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>

And of course I have restared my Apache server after adding this lines in those files. Unfortunatly typing myhost or www.myhost in my browser redirect me to the myhost/xampp.

I have already search and I have found on google and also on stackoverflow description how to configure virtual hosts using xampp but how can I recognize I have done everything alright. I know that my problem isn't new but I didn't found working solution for me.

I have also recognized that typing localhost in my browser redirect me alsto localhost/xampp. I don't know whether these problems are linked in my case.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had this same issue. Your first request is redirecting to the htdocs root directory. If you look at index.php in the htdocs directory, you can see very brief code that takes the incoming request and redirects it to the xampp directory.

I fixed it by fiddling with the httpd-vhosts.conf file. In your case, try making the following edits:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1> 
    DocumentRoot "C:xampphtdocs
    ServerName localhost
</VirtualHost>

<VirtualHost www.myhost> 
    DocumentRoot "C:UsersMeDropboxProjectpublic"
    ServerName www.myhost
    ServerAlias www.myhost
    <Directory "C:UsersMeDropboxProjectpublic">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...