问题描述
我最近一直在清理我的项目.我在根目录中有一个主要的 .htaccess,还有 6 个.其中 5 个运行 Options -Indexes
我没有看到任何允许任何目录查看的点,因此将其移至主要目录.所以现在我只有 2 个 .htaccess 文件./system
中的 main 和一个保存
I've been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes
which i didn't see anypoint of allowing any Directory viewing so moved that to the main one. so now i only have 2 .htaccess files. the main and one in /system
which holds
# Block External Access
deny from all
所以我想在 /system
上运行它,只在 main 中运行.所以我删除了/system 中的一个并添加了
So i wanted to run that on /system
only from within the main. So i deleted the one in /system and added
# Block External Access
<Directory "/system/">
deny from all
</Directory>
到我的主 .htaccess 文件,留下 1!
to my main .htaccess file leaving 1!
但现在我得到一个
内部服务器错误
服务器遇到内部错误或配置错误无法完成您的请求.
The server encountered an internal error or misconfiguration and was unable to complete your request.
请联系服务器管理员,webmaster@localhost 和通知他们错误发生的时间,以及您可能会做的任何事情已经做了可能导致错误的事情.
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) 服务器在 10.0.1.5 端口 80
Apache/2.2.17 (Ubuntu) Server at 10.0.1.5 Port 80
目标是阻止读取/system 及其子目录中的任何文件,但允许查看整个项目的一个 .htaccess
文件中的所有其他内容.关于如何解决这个问题的任何想法?我在 Google 上进行了一些搜索,但没有真正找到任何东西.
The goal is to block reading any files in /system and it's sub directory's but allow viewing of everything else all from one .htaccess
file for the whole project. Any ideas on how i can fix this? I did some Google searches but couldn't really come out with anything.
推荐答案
您不能使用 目录指令.但是,如果您在/system 目录中创建一个 .htaccess 文件并将以下内容放入其中,您将获得相同的结果
You cannot use the Directory directive in .htaccess. However if you create a .htaccess file in the /system directory and place the following in it, you will get the same result
#place this in /system/.htaccess as you had before
deny from all
这篇关于htaccess <目录>拒绝所有人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!