htaccess的保护所有子文件夹和放大器;档 [英] htaccess protect all subfolders & files

查看:104
本文介绍了htaccess的保护所有子文件夹和放大器;档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种情况:

/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屋!

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