简体   繁体   English

Apache虚拟主机无法在子域正常运行

[英]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. 我正在积极开发一个在localhost上设置的网站,我想在localhost上设置一个子域,使我的生活更轻松10 *。

I added this to C:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf : 我将此添加到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. Apache统计信息正常,但是当我导航到http://localhost/我看到了来自i1子域的内容。 http://i1.localhost/ works fine, however. http://i1.localhost/可以正常工作。

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/ . localhosti1.localhost我都看到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: Apache通常不喜欢另一个虚拟主机中的虚拟主机文档根目录,请尝试:

DocumentRoot "C:/xampp/htdocs/" DocumentRoot“ C:/ xampp / htdocs /”

and

DocumentRoot "C:/xampp/i1/" DocumentRoot“ C:/ xampp / i1 /”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM