显示器上的Apache任何错误500错误 [英] Display 500 error on any error in apache

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

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/3075174/how-to-make-php-set-http-status-$c$c-to-500-automatically-in-case-of-any-error-c\">How使PHP设置HTTP状态code至500中的任何​​错误情况时自动? (包括那些不能由用户来处理)

我想配置Apache向用户发送一个500响应与自定义页面500当PHP脚本提出了一个致命的错误。
我现在是,它会打印的页面内容,这是很好的发展,但不用于生产错误的内联。

I want to configure Apache to send to the user a 500 response with a custom 500 page when a PHP script raises a fatal error. What I have now is that it will print the error inline with the page content which is good for development but not for production.

我如何配置Apache向用户发送带有自定义页面500回应?

How do I configure Apache to send the user a 500 response with a custom page?

推荐答案

假设你不仅要发送 500 头(很简单),但Apache的系统确实引发500错误,似乎有不平凡的解决方案。

Assuming that you don't only want to send a 500 header (which is easy), but really trigger a 500 error in Apache's system, there seems to be no trivial solution.

据<一个href=\"http://stackoverflow.com/questions/3075174/how-to-make-php-set-http-status-$c$c-to-500-automatically-in-case-of-any-error-co\">this问题,它的的自PHP 5.2.4 PHP的默认行为:

According to this question, it is PHP's default behaviour since PHP 5.2.4 if:


  1. 发生致命错误和

  2. 文档正文为空(戈登发现changelog的项目<一个href=\"http://stackoverflow.com/questions/3075355/php-emitting-500-on-errors-where-is-this-documented\">here).

  1. a fatal error occurs and
  2. the document body is empty (Gordon found the changelog entry here).

我不知道这种行为是如何可靠是长期的(即,当PHP 6出现等)。这不是一个太大标榜的功能。

I'm not sure how reliable this behaviour is long term (i.e. when PHP 6 comes up etc.). It's not a much advertised feature.

除此之外,据我所知,没有办法运行脚本后挑起了500。我问<一个href=\"http://stackoverflow.com/questions/2447106/redirect-to-apache-built-in-404-page-with-mod-rewrite\">something类似为404次。只要答案(重定向到predefined URL,并发送一个500头)可能是你能得到最好的 - 尽管这当然不会被记录。

Other than that, I know of no way of provoking a 500 once the script runs. I asked something similar for 404s once. The answer provided there (redirecting to a predefined URL, and sending a 500 header) may be the best you can get - although that of course won't be logged.

这篇关于显示器上的Apache任何错误500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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