我尝试了在 apache 文档中找到的所有内容以及在 stackoverflow 和博客中找到的其他建议。当我将以下行添加到任何配置文件(如/etc/apache2/apache2.conf
or/etc/apache2/conf.d/localized-error-pages
或/etc/apache2/httpd.conf
or )时/etc/apache2/sites-enabled/000-default
:
ErrorDocument 503 "This is an error msg"
甚至是 html 消息
ErrorDocument 503 "<h1> This is an error message </h1>
或外部 url 重定向ErrorDocument 503 http://www.google.com
它都有效。
但是当我尝试像这样的内部重定向ErrorDocument 503 /ERROR_503.html
或者ErrorDocument 503 /error/ERROR_503.html
我得到最后一行的默认消息时:
此外,在尝试使用 ErrorDocument 处理请求时遇到 503 Service Temporarily Unavailable 错误。
我试图将 html 错误页面放在 DocumentRootvar/www
的var/www/error
. 尝试取消注释所有/etc/apache2/conf.d/localized-error-pages
将所有错误设置为具有国际化的自定义页面的文件/usr/share/apache2/error
。由于此文件中的消息与默认值相同,因此该行
此外,在尝试使用 ErrorDocument 处理请求时遇到 503 Service Temporarily Unavailable 错误。不再显示。但是如果我换行
`ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var`
将localized-error-pages 文件中的新html 放置在同一页面上,错误又回来了,并且该页面未显示。如果我编辑文件HTTP_SERVICE_UNAVAILABLE.html.var
,浏览器消息也没有任何变化。
更多信息:我使用 apache2 只是通过工作人员将端口 80 上的所有请求重定向到端口 8089 上的 tomcat。我的配置文件是https://dl.dropboxusercontent.com/u/1105054/apache.zip