1、需求:将 http://localhost/ 的请求全部转向 http://localhost/demo/

测试环境:wamp

错误解决:

http.conf文件末尾加上

Alias / "/demo/"

<Directory "/demo/">

Options Indexes

Order Allow, Deny

Allow from all

</Directory>

正确方法:

Alias / "E:/wamp/www/demo/"

<Directory "E:/wamp/www/demo/">

Options Indexes

Order Allow, Deny

Allow from all

</Directory>

错误分析:linux支持相对路径,windows需用绝对路径

2、FollowSymlinks的使用

Options Indexes, FollowSymlinks 在linux下就有权限访问目录下的链接文件,windows下的链接文件访问时后缀为.ln 访问时出现乱码

3、如何阻止文件被访问

/

  hello.html

  static

     hello.html

      js

         hello.html

         hello.htm

问题一:所以的hello.html 都不可被访问

              <Files "hello.html">

                       Order Deny,Allow(注:deny与allow之间不得有空格,否则wamp出错)

                       Deny from all

              </Files>

 

问题二:只有根目录下的helo.html能够被访问

Alias / "E:/wamp/www/demo/"

<Directory "E:/wamp/www/demo/">

Options Indexes

Order Allow, Deny

Allow from all

           <Files "hello.html">

                       Order Deny,Allow(注:deny与allow之间不得有空格,否则wamp出错)

                       Deny from all

              </Files>

</Directory>

这样配置,windows下仍然是所以的hello.html都无法访问,linux下未测试,老师测试成功

3、static下的hello.html不可访问

4、js目录下的hello.htm不可访问(用FilesMatch实现)