【发布时间】:2013-07-16 06:29:40
【问题描述】:
我的方法是 - 除了我熟悉的以外,否认一切。
我想允许访问root、index.php 和familiar 'safe' extensions。
因此,我不必考虑我应该保护什么,而是考虑我不应该保护什么。
这是我的 .htaccess 文件的外观:
# Disable files and directories index listing
Options -Indexes
DirectoryIndex index.php
# Deny all files.
<FilesMatch ".">
Order Deny,Allow
Deny from all
</FilesMatch>
# Except index.php
<FilesMatch "index.php$">
Order Allow,Deny
Allow from all
</FilesMatch>
# Except root
<FilesMatch "^$">
Order Allow,Deny
Allow from all
</FilesMatch>
# And except familiar extensions
<FilesMatch "\.(css|js|jpe?g|png|gif)$">
Order Allow,Deny
Allow from all
</FilesMatch>
一切正常,除非我尝试访问不带斜杠的地址:http://localhost/site 而不是 http://localhost/site/,
然后我得到“禁止”错误页面。
非常感谢一些帮助。
【问题讨论】: