gpt4 book ai didi

apache - 如何使用 Require 指令来限制 apache 2.4 中的文件访问

转载 作者:行者123 更新时间:2023-12-01 00:59:14 25 4
gpt4 key购买 nike

对于运行 apache 2.4.7 的 Ubuntu 14.04 网站,我有一个类似于以下的目录结构:

/websites/mywebsite/index.htm
/websites/mywebsite/private.htm
/websites/myqwbsite/folder/privatefile.ext
/websites/mywebsite/folder/subfolder/publicfile.ext
在该站点的 Apache 配置中,我有
<Directory /websites/mywebsite/>
AllowOverride Limit
Require all granted
</Directory>
我想在站点文件夹中使用 .htaccess 文件,这样 private.htm 和 privatefile.ext 文件是 Require all denied但其他一切都被授予。
我尝试了以下两个 .htaccess 文件:
/websites/mywebsite/.htaccess:
<FilesMatch (private.*.htm)$>
Require all denied
</FilesMatch>
/websites/mywebsite/folder/.htaccess :
Require all denied
/websites/mywebsite/folder/subfolder/.htaccess :
Require all granted
但是,apache 为 /websites/mywebsite/.htaccess 给出了 500 - “此处不允许要求”
如何使用与 apache 2.4 兼容的配置(即我不想加载 mod_access_compat 并使用旧样式配置)来实现我想要的?

最佳答案

在站点的 apache 配置中,您必须扩展 AllowOverride 属性。添加:FileInfo 和 AuthConfig。或者设置“AllowOverride All”

我有同样的问题,用这个配置修复:

<Directory /websites/mywebsite/>
Options +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride FileInfo AuthConfig
</Directory>

关于apache - 如何使用 Require 指令来限制 apache 2.4 中的文件访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24966546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com