开发者

Apache virtual-host not working correctly for subdomain

I've got a site set up on localhost that I'm actively developing, and I'd like to set up a subdomain on localhost to make my life 10* easier.

I added this to C:\xampp\apache\conf\extra\httpd-vhosts.conf:

<VirtualHost i1.localhost:80>
    ServerAdmin dummy@localhost
    DocumentRoot "C:/xampp/htdocs/i1/"
    ServerName i1.localhost
    ServerAlias www.i1.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

Apache stats up fine, but when I navigate to http://localhost/ I'm seeing content from the i1 subdomain. http://i1.localhost/ works fine, however.

Then I tried doing this:

<VirtualHost localhost:80>
    ServerAdmin dummy@localhost
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost
    ServerAlias www.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog 开发者_运维技巧"logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

<VirtualHost i1.localhost:80>
    ServerAdmin dummy@localhost
    DocumentRoot "C:/xampp/htdocs/i1/"
    ServerName i1.localhost
    ServerAlias www.i1.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

But that worked the opposite. On both localhost and i1.localhost I'm seeing content from C:/xampp/htdocs/.

Anyone got an idea what's going wrong?

Cheers.


Apache usually does not like a vhosts document root inside another vhost, try:

DocumentRoot "C:/xampp/htdocs/"

and

DocumentRoot "C:/xampp/i1/"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜