【发布时间】:2020-04-14 06:40:08
【问题描述】:
如何防止直接访问应用程序中的文件夹/文件等文件?
我在应用程序文件夹中看到的文件 .htaccess 和 index.html 包括:
.htaccess
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
index.html
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
我在根项目目录中创建一个新文件夹,名称为:Customers where will be stored customers PDF files。我将两个文件 .htaccess 和 index.html 从应用程序粘贴到客户,但 PDF 文件仍然能够直接访问。
如何让它们像应用程序文件夹文件一样只能访问系统?
【问题讨论】:
-
你可以在这里找到一个很好的答案stackoverflow.com/questions/37981011/…
-
@sintakonte 这是如何分离系统和应用程序文件夹,我正在寻找如何创建只有 codeigniter 系统才能访问里面的文件的新文件夹
-
以这种方式思考 - 如果您以这种方式设置 apache vhost - 应用程序文件夹位于公共根目录之外 - 因此您可以在应用程序目录中创建一个文件夹,例如
application/uploads/customers由于您的设置更安全而自动受到保护 -
@sintakonte 我的帐户是有限的,不像所有者帐户,我没有访问当前项目文件夹之外的权限。
-
@sintakonte 有没有办法拒绝所有未登录用户访问特殊文件夹/文件?
标签: php .htaccess codeigniter