我知道这个问题已被问过好几次了,我甚至在我的公司里做了很多次,但是,现在我想在家里设置一个虚拟主机并且它不起作用。
我做了什么:
Added xxx.localhost.de into the hosts
127.0.0.1 xxx.localhost.de
Uncommented include vhosts... in my httpd.conf
Include conf/extra/httpd-vhosts.conf
Set up a virtual host for my project
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
我没有得到错误 - wamp仍然正常,我可以通过使用正常路径localhost/...
访问它,但当我尝试通过xxx.localhost.de到达它时,我进入网站“www.localhost.de”。它表现得像他不关心我的主机文件......
我究竟错过了什么?在我的公司里,它总是像这样工作。我已经检查了教程,它总是说这是所有需要的步骤。
谢谢!
我也有同样的问题,有几件事可以导致这种情况,首先尝试添加DirectoryIndex index.php
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:\wamp\www\xxx"
DirectoryIndex index.php
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
然后你可以尝试在你的浏览器中写“http://you_address.local,如果这没有帮助,我会想到任何其他可能导致
试试这个 :-
将HOSTS文件更改为: -
127.0.0.1 localhost
::1 localhost
127.0.0.1 project1.dev
::1 project1.dev
而Vhost定义为
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:\wamp\www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "D:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName project1.dev
ServerAlias www.project1.dev
ErrorLog "logs/project1-error.log"
CustomLog "logs/project1-access.log" common
<Directory "D:/wamp/www/xxx">
AllowOverride All
Require local
</Directory>
</VirtualHost>
看来我必须对hosts.ics
文件进行更改,而不是标准的hosts
文件。它工作得很好