我有一个目录结构,如下所示,用于运行在Ubuntu 14.04上的Apache 2.4.7网站:
/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文件的访问被拒绝
,而其它文件则允许。
我尝试了以下两个.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错误 - "Require not allowed here"。
我该如何使用与Apache 2.4兼容的配置实现我想要的功能(即,我不想加载mod_access_compat并使用旧的样式配置)?
/websites/mywebsite/folder/subfolder/
目录下放置.htaccess
文件。所有其他.htaccess
文件都被删除了。尽管Apache文档明确表示允许在那里使用"Require",但Apache仍然声称"Require not allowed here"。详情请参考:http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require - dodexahedron