我有一个文件夹,其中包含以下几个文件和子文件夹:
-/folder
-/subfolder
-/subfolder
-/subfolder
-/etc...
-index.html
-control.php
-ads.php
-/etc...
现在我想禁用工作PHP或其他文件在主目录(-/文件夹),如(-index.html, -control. PHP),但所有子文件夹文件我想工作得很好。
我只想对主文件夹内的文件生效
如果我理解正确,您需要在给定目录中使用以下内容的.htaccess:
deny from all
编辑:因为据我所知。htaccess规则也适用于所有子目录,你可能必须在每个子目录中创建一个。htaccess文件来覆盖为根目录
指定的限制allow from all
.htaccess文件中的配置指令被应用于找到.htaccess文件的目录,以及所有子目录。
http://httpd.apache.org/docs/current/howto/htaccess.html如何
你可以使用多个指令来覆盖第一个指令
<directory /path/to/dir>
Order Allow,Deny
Deny from All
</directory>
<directory /path/to/dir/subdir>
Order Deny,Allow
Allow from All
</directory>
如果您使用的是apache,您可以在虚拟主机中添加
<directory /path/to/dir>
Order allow,deny
Deny from All
</directory>
指令对于每个子目录,参见http://httpd.apache.org/docs/2.2/howto/access.html
(我希望我能理解你的需要)
编辑如果需要过滤文件而不是目录,可以使用像
这样的glob匹配<Files *.php>
Order allow,deny
Deny from All
</Files>
看到http://httpd.apache.org/docs/2.2/en/mod/core.html文件