拒绝的.htaccess子文件夹中的文件 [英] .htaccess deny files in subfolders

查看:245
本文介绍了拒绝的.htaccess子文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想阻止访问子/文件夹/的index.php,而不是的index.php其他地方。

I want to block access to "sub/folder/index.php", but not "index.php" anywhere else.

<Files index.php>
    Order allow,deny
    Deny from all
</Files>

的作品,但会阻止所有的index.php文件。

works but blocks all "index.php" files.

<Files sub/folder/index.php>
    Order allow,deny
    Deny from all
</Files>

不起作用。我是否需要使用&LT;目录&GT;

我不希望创建在子/文件夹的.htaccess文件

我没有获得的httpd.conf

我不想阻止一切分/目录

如果它是那么容易,我就不会问;)

If it were that easy, I wouldn't be asking ;)

推荐答案

我觉得simpliest规则是:

I think the simpliest rule is:

RedirectMatch 403 ^.*/sub/folder/index\.php$

RedirectMatch是mod_alias中的模块,你肯定有。这并不意味着mod_rewrite的发动机。在这里,我们只是告诉Apache的任何进入子/文件夹/ index.php文件将产生一个403禁止的答案。

RedirectMatch is in mod_alias module, that you certainly have. This does not implies mod_rewrite engine. Here we are simply telling apache that any access to sub/folder/index.php will generate a "403 forbidden" answer.

您可以把在一个httpd.conf文件或根的.htaccess(但真正考虑删除所有的.htaccess,这是不好的,它的速度慢,这是可悲的,你没有进入到真正的配置文件)。

You can put that in a httpd.conf or in the root .htaccess (but really consider removing all .htaccess, it's bad, it's slow, it's sad that you do not have access to the real configuration files).

这篇关于拒绝的.htaccess子文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆