开发者

Apache virtual-host not working correctly for subdomain

开发者 https://www.devze.com 2023-03-25 05:15 出处:网络
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'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

精彩评论

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

关注公众号