今天在wamp集成环境下配虚拟主机,没想到虚拟主机开启后,localhost竟然无法访问了,访问 http://localhost/ 提示 403 Forbbiden。觉得可能跟我设置了虚拟主机有关系,因为
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
注释掉,localhost就可以访问。
可能是因为开了虚拟主机,默认访问的目录就变成虚拟主机配置文件下的那些目录,所以讲/wamp/www添加到虚拟主机配置目录下,就可以了。
D:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:\wamp\www"
ServerName localhost
ServerAlias local
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>