wamp配置虚拟路径(路径别名)
wamp默认的路径是安装目录下的 www 目录,
如果你想运行php代码,就需要将代码放在 www 目录下,
但这样很不方便,能否通过配置的方式,来实现 在别的目录下的 php 代码,也能正常运行和访问到呢。
答案是 可以的。
Alias /github "h:/github_projects" <Directory "h:/github_projects/"> #Options Indexes FollowSymLinks #AllowOverride None #Order allow,deny #Allow from all Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory>
在配置文件 httpd.conf 中,添加上述代码,重启即可。
Alias /github "h:/github_projects"
指定真实路径 h:/github_projects 的别名(映射名)为 /github,
这样就能通过 http://localhost/github/xxxxx 来访问 h:/github_projects目录下的 xxxxx 项目了
完整的配置例子:(解决403和指定别名)
1 <VirtualHost *:80> 2 ServerName localhost 3 DocumentRoot e:/wamp64/www 4 <Directory "${INSTALL_DIR}/www/"> 5 Options +Indexes +Includes +FollowSymLinks +MultiViews 6 AllowOverride All 7 Require all granted 8 </Directory> 9 10 Alias /github "h:/github_projects" 11 12 <Directory "h:/github_projects/"> 13 #Options Indexes FollowSymLinks 14 #AllowOverride None 15 #Order allow,deny 16 #Allow from all 17 18 Options +Indexes +Includes +FollowSymLinks +MultiViews 19 AllowOverride All 20 Require all granted 21 </Directory> 22 </VirtualHost>
参考:http://www.111cn.net/phper/apache/52812.htm
https://stackoverflow.com/questions/38339617/wamp-server-403-forbidden-using-a-public-ip-works-with-localhost-and-ipv4-addre/38347450#38347450