【问题标题】:Apache Error Document is not workingApache 错误文档不起作用
【发布时间】:2011-07-13 12:33:42
【问题描述】:

我在 linux 环境中运行 apache2 网络服务器。我想将用户重定向到自定义错误页面。因此创建了错误页面并在 htdocs 中创建了符号链接,也是这样。静态文件-> /app/静态文件。 在 httpd.conf 文件中,我创建了虚拟主机定义并包含错误页面,如下所示:

NameVirtualHost m.mydomain.com:80

    <VirtualHost m.mydomain.com:80>
    DocumentRoot "/app/httpd-2.2.15/htdocs"
    ServerName m.mydomain.com:80

    <Directory "/static-files/html/error_pages">
     Options FollowSymLinks
      Order allow,deny
      Allow from all
    </Directory>

    ErrorLog /app/httpd-2.2.15/logs/error_my_log
    ErrorDocument 400 /static-files/html/error_pages/error_400.html
    ErrorDocument 401 /static-files/html/error_pages/error_401.html
    ErrorDocument 403 /static-files/html/error_pages/error_403.html
    ErrorDocument 404 /static-files/html/error_pages/error_404.html
    ErrorDocument 408 /static-files/html/error_pages/error_408.html
    ErrorDocument 500 /static-files/html/error_pages/error_500.html
    ErrorDocument 501 /static-files/html/error_pages/error_501.html
    ErrorDocument 502 /static-files/html/error_pages/error_502.html
    ErrorDocument 503 /static-files/html/error_pages/error_503.html
    ErrorDocument 504 /static-files/html/error_pages/error_504.html
    </VirtualHost>

当我的应用服务器关闭时,它不会将我重定向到 503 自定义错误页面。我只获取服务器特定的错误页面。但是如果我将此 ErrorDocument 放在虚拟主机定义之外,它会将我重定向到自定义错误页面.我打了3天头。但找不到原因。我在所有浏览器中都试过了。任何人都可以帮助我吗?

【问题讨论】:

    标签: virtualhost apache2.2 errordocument


    【解决方案1】:

    由于您将 DocumentRoot 定义为“/app/httpd-2.2.15/htdocs”,因此错误页面应位于此目录中。您确定错误页面在此目录中吗?

    【讨论】:

      【解决方案2】:

      我不能 100% 确定,但是当您有一个在 Apache 后面运行的应用服务器并且当它关闭时,您会发现 404 未找到。 这不是 503 答案。当服务器(应用服务器的 Apache)出现故障时会发生 503,例如负载或未配置配置后可能发生的任何事情。

      【讨论】:

      • 但是我的访问日志中显然出现了 503 错误。当我将 ErrorDocument 放在虚拟主机定义之外时,它也会重定向到 503 ErrorDocument。
      猜你喜欢
      • 2013-08-20
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 1970-01-01
      • 2012-07-01
      相关资源
      最近更新 更多