1.打开apche配置文件httpd.conf,将Include conf/extra/httpd-vhosts.conf前面的#去掉;
2.在apache的目录下进入conf/extra;找到http-vhosts.conf文件,打开后在最后一行添加上如下代码后重启apache;
1 <VirtualHost *:80> 2 ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev 3 DocumentRoot "C:/wamp/www/hsy" 4 ServerName hsy.com 5 DirectoryIndex index.php 6 DirectoryIndex index.html 7 DirectoryIndex index.htm 8 ErrorLog "logs/dummy-host2.hleclerc-PC.ingenidev-error.log" 9 CustomLog "logs/dummy-host2.hleclerc-PC.ingenidev-access.log" common 10 </VirtualHost>
3.进入C:\WINDOWS\system32\drivers\etc目录,打开hosts文件,在下面添加127.0.0.1 test.com。