一、需求:将 http://localhost/ 的请求所有转向 http://localhost/demo/html
测试环境:wamplinux
错误解决:windows
http.conf文件末尾加上ide
Alias / "/demo/"测试
<Directory "/demo/">spa
Options Indexeshtm
Order Allow, Denyget
Allow from allit
</Directory>io
正确方法:
Alias / "E:/wamp/www/demo/"
<Directory "E:/wamp/www/demo/">
Options Indexes
Order Allow, Deny
Allow from all
</Directory>
错误分析:linux支持相对路径,windows需用绝对路径
二、FollowSymlinks的使用
Options Indexes, FollowSymlinks 在linux下就有权限访问目录下的连接文件,windows下的连接文件访问时后缀为.ln 访问时出现乱码
三、如何阻止文件被访问
/
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下未测试,老师测试成功
三、static下的hello.html不可访问
四、js目录下的hello.htm不可访问(用FilesMatch实现)