带有“拒绝所有”的 htaccess 文件它也拒绝子目录吗?
如果我有这样的目录结构:
- index.php
- public
- img
- css
- application
- controllers
- user
- admin
- models
- views
.htaccess
我使用index.php作为我的前端控制器,因此所有MVC类和文件都包含在内并且不需要目录访问。
在 .htaccess 中,我有 Deny from all
,它位于应用程序目录中。这是否也有效地拒绝了对应用程序目录下所有子目录的直接文件访问和目录列表?或者我是否也需要将 .htaccess 文件放入每个子目录中?
非常感谢
If I have a directory structure like this:
- index.php
- public
- img
- css
- application
- controllers
- user
- admin
- models
- views
.htaccess
I'm using the index.php as my front controller so all MVC classes and files are included and don't require directory access.
In the .htaccess I have Deny from all
inside it and it sits in the application directory. Does that effectively deny direct file access and directory listing to all the sub-directories under the application directory as well? Or do I need to put the .htaccess file inside each sub-directory as well?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的 - .htaccess 适用于目录内的整个树。要覆盖它的规则,您必须在子目录中添加给定的规则,然后新的 .htaccess 将适用于该子目录内的整个树。
Yes - .htaccess works for the whole tree inside the directory. To override it's rules you have to add the given rule in a subdir and then the new .htaccess will work for the whole tree inside that subdir.