Apache配置虚拟域名后,不能访问localhost的问题
先说配置虚拟域名的流程:
1.先打开httpd.conf文件,打开httpd-vhosts.conf
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
2.然后打开httpd-vhosts.conf文件,配置一个虚拟主机
<VirtualHost *:80>
DocumentRoot “D:/amp/www/wechat”
ServerName www.wechat.com
3.打开hosts文件,添加域名
127.0.0.1 www.wechat.com
4.重启Apache,这时虚拟域名www.wechat.com可以正常访问,但是localhost就不能访问了。
解决过程:
1.打开httpd-vhosts.conf文件,添加一个名为localhost的虚拟域名:
<VirtualHost *:80>
ServerName localhost
DocumentRoot “D:/amp/www”
2.打开http.conf文件中有一行代码是需要注释掉的
#ServerName localhost:80
以后无论开启或者关闭虚拟域名,localhost都可以正常访问。