对于运行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
但是,对于/websites/mywebsite/.htaccess
,apache给出了500-“此处不要求”如何通过apache 2.4兼容的配置(例如,我不想加载mod_access_compat并使用旧样式的config)来实现自己想要的事情?
最佳答案
在站点的apache配置中,您必须扩展AllowOverride属性。添加:FileInfo和AuthConfig。或设置“AllowOverride全部”
我有同样的问题,此配置已解决:
<Directory /websites/mywebsite/>
Options +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride FileInfo AuthConfig
</Directory>