以添加demo.com作虚拟主机,目录以W:/demo.com 为例
1.在 C:\Windows\System32\drivers\etc\hosts,添加:
127.0.0.1 demo.com
2.在 C:\wamp\bin\apache\apache2.4.23\conf\httpd.conf,查找:
# Virtual hosts # Include conf/extra/httpd-vhosts.conf 修改为: # Virtual hosts Include conf/extra/httpd-vhosts.conf
3.在 C:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf,添加几行代码:
<VirtualHost *:80> ServerName demo.com ServerAlias demo.com DocumentRoot "W:/demo.com <Directory "W:/demo.com/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost>
添加后需要重启服务器,三步完成。
时间: 2024-10-25 03:44:50