自定义页面错误500的错误 [英] Error for customize page error 500

查看:290
本文介绍了自定义页面错误500的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么我无法自定义错误500,但是它对于404、403很有帮助

I dont know why i cant customize error 500 but its good for 404, 403

我有这样的文件夹


  • www

    • index.php

    • .htaccess(2)


    • index.php

    第一个htaccess

    the first htaccess

    RewriteEngine on
    RewriteBase /
    
    # Error
    ErrorDocument 403 /error/index.php?error=403
    ErrorDocument 404 /error/index.php?error=404
    ErrorDocument 500 /error/index.php?error=500
    

    然后第二个

    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.+)/$ /www/index.php?v=$1 [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ /www/index.php?v=$1 [QSA,L]
    

    谢谢

    推荐答案

    自定义错误500页是最难使用的。问题是,服务器为什么会抛出 500内部服务器错误有很多原因。仅当Apache可以处理500的原因以显示页面时,500的自定义页面才起作用。假设您在.htaccess页面或apache配置文件中犯了语法错误,它将引发 500服务器错误,但是因为Apache是​​ down ,它不能提供任何服务,包括该自定义页面,因此您获得了浏览器的默认页面。另外,根据您的PHP错误报告设置方式,您也不会获得500个自定义页面。此功能还有很多,自定义500页几乎是无用的,因为大多数人都不会看到。您会提前知道的,因为它通常是500个配置问题,例如代码中的语法错误。

    Customized Error 500 pages are the hardest to use. The problem is, there are many reasons why a server can throw a 500 internal server error. Custom pages for 500 only work if the cause of the 500 can be handled by Apache to display the page. Say for instance you made a syntax error in your .htaccess page or in your apache config file, it's going to throw a 500 server error but because Apache is down, it can't serve anything including that custom page, so you get the browsers default page. Also depending on how you have your PHP error reporting setting you won't get 500 custom page either. There is a lot more to this and customizing 500 page is almost useless cause most people won't ever see that. You will know before they will because it's a 500 is typically configuration issue, like a syntax error in your code.

    503 是用户会看到的最常见的页面,尤其是如果您的站点需要维护时,这些页面就是我会重点关注的。

    503 is the most common page a user will see especially if your site is down for maintenance and those are the one's I would focus on.

    无论如何,我将在此链接上查看有关500个自定义页面的更多信息,以了解何时以及为什么它将不起作用。

    Anyway, I'd take a look at this link to see more info on 500 custom pages on when and why it won't work.

    Apache的ErrorDocument指令不会重定向

    也来自Apache文档

    Also from Apache docs


    尽管大多数错误消息都可以被覆盖,在某些
    情况下,无论ErrorDocument的
    设置如何,都使用内部消息。特别是,如果检测到格式错误的请求
    ,则将立即停止正常的请求处理,并返回
    内部错误消息。这对于防止由于错误请求而引起的
    安全问题是必要的。

    Although most error messages can be overridden, there are certain circumstances where the internal messages are used regardless of the setting of ErrorDocument. In particular, if a malformed request is detected, normal request processing will be immediately halted and the internal error message returned. This is necessary to guard against security problems caused by bad requests.

    http://httpd.apache.org/docs/2.4/mod/core.html#errordocument

    这篇关于自定义页面错误500的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆