0

我为本地开发安装了 XAMPP,我想为每个项目创建一个子域。在我的 apache vhosts 配置中,我放了这个:

<VirtualHost localhost:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

<VirtualHost nexus.localhost:80>
DocumentRoot C:/xampp/htdocs/nexus/
ServerName nexus.localhost
ServerAdmin admin@nexus.localhost
</VirtualHost>

在我的 Windows 主机文件中:

# development
127.0.0.1 localhost
127.0.0.1 nexus.localhost

localhost 正常工作。如在,如果我去http://localhost/project_name一切正常。但是,如果我导航到http://nexus.localhost/我只会得到Object not found!错误。

这里有什么问题?谢谢你。

4

1 回答 1

0

文档http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost<VirtualHost>指令应该包含 IP 地址,所以试试这个:

<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/nexus/
ServerName nexus.localhost
ServerAdmin admin@nexus.localhost
</VirtualHost>
于 2012-05-18T19:17:17.813 回答