作者:Lee_ruxing
转自:http://blog.youkuaiyun.com/liruxing1715/article/details/7864309
Apache 配置虚拟目录是什么意思呢?
假如您现在的 Apache 配置文件(httpd.conf)中设置的访问路径为:E:/php/web 下,即DocumentRoot "E:/php/web"。哪如何设置一个别的盘符(比如:D盘)下面的一个目录,让 Web 服务器可以去访问呢?就需要配置虚拟目录。
下面为配置步骤:
1、配置虚拟目录就是增加一个节点,找到<IfModule>这块,加入下面的代码;
- # 虚拟目录,访问D盘下面的web目录
- <IfModule dir_module>
- # 设置缺省载入页面
- DirectoryIndex index.html index.htm index.php
- # 设置站点别名,别名与访问路径是相关的,取任何名称都可以(除特殊)
- Alias /myweb "D:/web"
- <Directory D:/web>
- # 设置访问权限
- Order allow,deny
- Allow from all
- </Directory>
- </IfModule>
2、可以把之前的 DocumentRoot 注释掉(也不可);
- #DocumentRoot "E:/php/web"
3、在浏览器中输入:http://localhost/myweb/xx.php 来访问 D:/web 下的文件