大网数据广告活动
服务器运维问答

Why is Apache reading .htaccess files even though they are disabled?

· 52CE 我爱测

According to Apache documentation, setting the AllowOverride and AllowOverrideList options to None , will completely ignore .htaccess files. Not even attempt to read them from the filesystem. I have both of those options set to n…

问题原文

原帖链接 · NOYB · CC BY-SA 4.0

According to Apache documentation, setting the AllowOverride and AllowOverrideList options to None, will completely ignore .htaccess files. Not even attempt to read them from the filesystem.

I have both of those options set to none but Apache still reads the .htaccess files. I know this because if I put a .htaccess file in with some valid directives it throws a 500 error. Commenting out the directives (essentially an empty .htaccess file) the 500 error is not thrown. So obviously Apache is still reading the .htaccess files.

Apache2 error log (sanitized for public consumption):
[Thu Jul 30 23:36:35.393831 2020] [core:alert] [pid 60903] [client d.d.d.d:10554] /var/www/example/.htaccess: Require not allowed here, referer: http://example.net/

The question is why? What am I missing? How to make it behave according to the documentation? i.e. not even attempt to read the .htaccess files.

Reference: https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

When this directive is set to None and AllowOverrideList is set to None, .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 4.0

This would appear to be a bug in earlier versions of Apache 2.4 that was reportedly fixed in Apache 2.4.20
https://bz.apache.org/bugzilla/show_bug.cgi?id=58528

The bug would seem to be that when explicitly setting AllowOverrideList None the value is not being correctly reset.

I have verified that I see the same (incorrect) behaviour in Apache 2.4.7

If you have never set AllowOverrideList elsewhere in your server config then you can omit this directive, since the default is None. (When left as default it does appear to be correctly interpreted as per the docs.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。