就是说我的现在网站是:www.a.com 对应目录是d:\xampp\htdocs\a
我想添加另外一个网站:www.b.com 对应目录是d:\xampp\htdocs\b
但是参照网上搜索的说明设置后,www.b.com访问的还是d:\xampp\htdocs\a目录,试了多次每一次成功过,请知道帮忙解决下!谢谢
下面是我的设置:
1、首先修改C盘WINDOWS\system32\drivers\etc目录下的hosts文件,用记事本打开,加入:
127.0.0.1 www.a.com
127.0.0.1 www.b.com
2、打开httpd.conf文件,加入许可:
<Directory "d:\xampp\htdocs\a">
Order allow,deny
Allow from all
</Directory>
<Directory "d:\xampp\htdocs\b">
Order allow,deny
Allow from all
</Directory>
3、在虚拟主机设置文件httpd-vhosts.conf里设置:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot /xampp/htdocs/a
ServerName www.a.com
## ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
## CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot /xampp/htdocs/b
ServerName www.b.com
## ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
## CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
</VirtualHost>
========================================================================
找到问题所在了
把文件httpd-vhosts.conf里:
#NameVirtualHost *:80
把去掉#就好了
修改www.a.com到127.0.0.1
C:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 www.a.com