1. 启动wampserver服务,左键单击右下角wampserver图标,打开Apache菜单下“httpd.conf”文件; 找到“# Include conf/extra/httpd-vhosts.conf” ,把这句前面的#号去掉,启用了虚拟主机配置文件 httpd-vhosts.conf 的引用。
2. 在Apache安装目录的confextra目录下,比如我的是 D:\wamp\bin\apache\apache2.2.22\conf\extra,用记事本打开httpd-vhosts.conf
添加一下代码:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/wamp/www/xxx "
ServerName www.xxx.com
<Directory "E:/wamp/www/xxx ">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3. 用记事本打开 c:\windows\system32\drivers\etc 目录下hosts文件,在最下面添加一行:
127.0.0.1 www.xxx.com