Possible Duplicate:
How to make PHP set HTTP status code to 500 automatically in case of any error condition? (including those that cannot be handled by user)
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.
How do I configure Apache to send the user a 500 response with a custom page?
Assuming that you don’t only want to send a
500header (which is easy), but really trigger a 500 error in Apache’s system, there seems to be no trivial solution.According to this question, it is PHP’s default behaviour since PHP 5.2.4 if:
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.
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.