In c:/WINDOWS/system32/drivers/etc/hosts:
- Code: Select all
127.0.0.1 localhost
127.0.0.1 local.site1.com
127.0.0.1 local.site2.com
127.0.0.1 local.site3.com
In c:/localhost/apache/conf/httpd-conf:
- Code: Select all
Include conf/extra/httpd-vhosts.conf
In c:/localhost/apache/conf/extra/httpd-vhosts.conf:
- Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
ServerAdmin admin@localhost
DocumentRoot 'c:/localhost/htdocs'
</VirtualHost>
<VirtualHost *:80>
ServerName local.site1.com
ServerAlias site1
ServerAdmin admin@site1
DocumentRoot c:/localhost/htdocs/private/site1
</VirtualHost>
<VirtualHost *:80>
ServerName local.site2.com
ServerAlias site2
ServerAdmin admin@site2
DocumentRoot c:/localhost/htdocs/private/site2
</VirtualHost>
<VirtualHost *:80>
ServerName local.site3.com
ServerAlias site3
ServerAdmin admin@site3
DocumentRoot c:/localhost/htdocs/private/site3
</VirtualHost>
http://localhost/ redirects to http://localhost/xampp/
I've left all the original files in the htdocs directory so this is expected and desirable.
http://localhost/private/ displays the standard index showing files and directories
This is also as expected and desirable. I can make this my default home page and select projects easily.
http://localhost/private/site1/ diplays the index.php at that address. Same for site2 and site3.
So far so good.
The Problem:
Any reference to '/' is interpreted as c:/localhost/htdocs/ instead of c:/localhost/htdocs/private/site1/
This ONLY happens in site1! The other two work perfectly.
There is an easy workaround... just put a dummy definition in httpd-conf where site1 is.
But it's driving me crazy. Why doesn't site1 work?