【前言】
Apache配置虚拟主机后,不能访问localhost,只能通过设置好虚拟域名访问。
可以通过把localhost变成虚拟域名。
参考文件:http://570109268.iteye.com/blog/2414410
【主体】
(1)设置虚拟域名
先在httpd-vhosts.conf设置好虚拟域名localhost
<VirtualHost _default_:80> DocumentRoot "C:\phpStudy\" ServerName localhost </VirtualHost>
(2)把httpd.conf文件的ServerName localhost:80 那行注释掉
(3)别忘了查看hosts文件里是否绑定 localhost指向127.0.0.1,一般情况下会存在
(4)重要的是第二点,要注释掉httpd.conf文件的ServerName localhost:80
.