以下方式适合原生 Apache, XAMPP 和 WAMP 套件
1.修改Apache配置文件(httpd.conf),如下:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2.修改虚拟主机配置文件(confextrahttpd-vhosts.conf),添加配置信息如下:
NameVirtualHost *:80 <VirtualHost *:80> ServerName mall.abc.com ServerAlias passport.abc.com www.abc.com my.abc.com DocumentRoot "E:/mall.abc.com" <Directory "E:/mall.abc.com"> Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName demo.abc.com DocumentRoot "D:/web/abc.abc.com" <Directory "D:/web/abc.abc.com"> Allow from all </Directory> </VirtualHost>
<VirtualHost *:80>
ServerName www.work.com
DocumentRoot "E:/Work/www.work.com"
<Directory "E:/Work/www.work.com">
Options Indexes MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3.重启Apache
注意:
apache的版本高了,部分语法修改
<VirtualHost *:8001> ServerName mall.abc.com DocumentRoot "E:/shopbox-html" <Directory "E:/shopbox-html"> Options Indexes FollowSymLinks Require all granted </Directory> </VirtualHost>