我最近一直在清理我的项目。我的根目录中有一个主 .htaccess 和其他 6 个。其中 5 个运行了 Options -Indexes
,我没有看到任何允许任何目录查看的点,因此将其移至主目录。所以现在我只有 2 个 .htaccess 文件。 main 和 /system
中的一个包含
# Block External Access
deny from all
所以我想仅在主程序中在 /system
上运行它。所以我删除了/system中的一个并添加了
# Block External Access
<Directory "/system/">
deny from all
</Directory>
到我的主 .htaccess 文件留下 1!
但现在我得到了
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.17 (Ubuntu) Server at 10.0.1.5 Port 80
目标是阻止读取/system 及其子目录中的任何文件,但允许从整个项目的一个 .htaccess
文件中查看所有其他内容。关于如何解决这个问题有什么想法吗?我进行了一些 Google 搜索,但没有真正找到任何结果。
最佳答案
您不能使用Directory directive在 .htaccess 中。但是,如果您在/system 目录中创建一个 .htaccess 文件并将以下内容放入其中,您将得到相同的结果
#place this in /system/.htaccess as you had before
deny from all
关于apache - htaccess <目录> 拒绝所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683496/