一、修改httpd.conf文件
编辑配置文件: 目录:%xamppapacheconfhttpd.conf #确认以下是否开启 Include conf/extra/httpd-vhosts.conf #修改<Directory />参数 <Directory /> #AllowOverride none #Require all denied Options All AllowOverride All Require all granted </Directory>
#配置文本最后加入:
<Directory "D:/web/web1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "D:/web/web2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
二、配置虚拟目录
编辑配置文件: 目录:%xamppapacheconfextrahttpd-vhosts.conf #加入以下内容: <VirtualHost *:80> ServerAdmin web1@dummy-host2.example.com DocumentRoot "D:/web/web1" ServerName www.web1.com ErrorLog "logs/web1-error.log" CustomLog "logs/web1-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin web2@dummy-host2.example.com DocumentRoot "D:/web/web2" ServerName www.web2.com ErrorLog "logs/web2-error.log" CustomLog "logs/web2-access.log" common </VirtualHost>