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

Apache ErrorLog: cannot use a full URL in a 401 ErrorDocument directive --- ignoring

· 52CE 我爱测

I use the .htaccess file on my Apache to display custom error documents. This all works fine too. But I still see lots of this error in the log: [Thu Aug 13 10:38:31 2020] [notice] [client AH00113: /home/www/.htaccess:6 cannot us…

问题原文

原帖链接 · Gill-Bates · CC BY-SA 4.0

I use the .htaccess file on my Apache to display custom error documents. This all works fine too.

But I still see lots of this error in the log:

[Thu Aug 13 10:38:31 2020] [notice] [client AH00113: /home/www/.htaccess:6 cannot use a full URL in a 401 ErrorDocument directive --- ignoring!

Line 6 of my .htacess looks straight forward:

ErrorDocument 401 http://error.foo.bar/401.html

Why can't a full URL in a 401 ErrorDocument directive be used? Bug or Feature?

已采纳解答

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

You can use only local URL-path in response to code 401. It is because

when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. In addition, if you use a remote URL in an ErrorDocument 401, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, if you use an ErrorDocument 401 directive, then it must refer to a local document.

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

资料来源与适用范围

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

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

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