4

我在 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 放在虚拟主机定义之外,它会将我重定向到自定义错误页面。我打了三天头。但找不到原因。我在所有浏览器中都试过了。有人可以帮助我吗?

4

2 回答 2

1

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

于 2018-08-14T15:20:16.500 回答
0

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

于 2011-07-13T12:47:52.107 回答