方法1:
D:\wamp\bin\apache\Apache2.2.17\conf\httpd.conf文件下
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
下添加如下
NameVirtualHost *:80
<VirtualHost *:80>
ServerName aa.test.com
DocumentRoot "D:\wamp\www\test\aa"
<Directory "D:\wamp\www\test\aa">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
AllowOverride None
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName bb.test.com
DocumentRoot "D:\wamp\www\test\bb"
<Directory "D:\wamp\www\test\bb">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
AllowOverride None
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
方法2:
1.wamp\bin\apache\Apache2.2.17\conf 下编辑httpd.conf 将Include conf/extra/httpd-vhosts.conf,把前面注释符号“#”删掉。
2.编辑httpd-vhosts.conf,我把WAMPServer安装在D:/wamp,所以我这里的路径是D:\wamp\Apache2\conf \extra。
把里面的内容清空掉,换成下面的内容:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.host1.com
ServerAlias www.host1.com
DocumentRoot "D:/wamp/www/host1"
</VirtualHost>
4.修改C:/WINDOWS/system3/drivers/etc/host这个文件,用记事本打开,加上如下内容:
5.重启apache ok了
注意事项:ServerName www.host1.com 中的www.可以省略