Apache 错误文档不起作用

发布于 2024-11-19 20:24:36 字数 1380 浏览 10 评论 0原文

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

I am running the apache2 webserver in the linux environment.I want to redirect the users to customized error pages.So have created the error pages & created the symbolic link in the htdocs also like this. static-files -> /app/static-files.
And in the httpd.conf file I have created the virtual host definition and included the error pages also like below:

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>

When my app server is down,its not redirecting me to 503 customized error page.I am getting the server specific error page only.But if i put this ErrorDocument out of the virtual host definition its redirecting me to the customized error page. I am striking my head for 3 days.But not able to find the reason.I tried in all browsers.Anybody can help me ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑白记忆 2024-11-26 20:24:36

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

As you defined DocumentRoot to be "/app/httpd-2.2.15/htdocs", the error pages should be in this directory. Are you sure that the error pages are in this directory?

假面具 2024-11-26 20:24:36

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

I'm not 100% sure but when you have an app server running behind Apache and when it is down you have a 404 not found.
It's not a 503 answer. 503 occurs when there is fault on the server (either Apache of the App server) such as load or anything that could happen following a miss configuration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文