htaccess的保护所有子文件夹和放大器;档 [英] htaccess protect all subfolders & files
问题描述
我有这种情况:
/storage
index.php
other scripts.php
/files
-files and folders-
我要拒绝所有的HTTP请求中的所有文件和 /文件
子文件夹,但在同一时间允许访问 /存储
和运行这些PHP脚本。我尝试了一些规则,但他们要么保护的文件只上市或不允许访问所有的 /存储
文件夹。
I want to deny all the HTTP requests to all files and subfolders of /files
but in the same time allowing to access /storage
and run those PHP scripts. I tried some rules but they either protect only the listing of files or don't allow access to all the /storage
folder.
在的.htaccess
必须是外 /文件
(因为这个文件夹是由PHP访问用readfile
和的.htaccess
可以访问)。
The .htaccess
must be outside /files
(because this folder is accessed by PHP readfile
and .htaccess
could be accessible).
推荐答案
在IE下 /储存根.htaccess文件
目录,就把这行:
In your root .htaccess file i.e. under /storage
directory put this line:
RewriteRule ^files/ - [R=404,L,NC]
这将引发 404
来的任何东西文件/
子目录下的所有HTTP请求,而你的的.php
文件就可以包含在文件文件/
子目录。
This will throw 404
to all the HTTP requests for anything under files/
sub directory while your .php
files will be able to include files under files/
sub directory.
这篇关于htaccess的保护所有子文件夹和放大器;档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!