Apache ErrorDocument not working for PHP 500 error

user187708 picture user187708 · Feb 12, 2010 · Viewed 10k times · Source

I have a number of ErrorDocuments setup in my .htaccess file for errors such as 404, 401, 403 etc which all redirect to my error page but the ErrorDocument set for a 500 error is never displayed when PHP reports a 500. The 500 code is sent to the browser and the output is blank. Is there something special I need to do to enable 500 error documents for use with PHP?

My directives look like this:

ErrorDocument 401 /errorpage.php?error=401
ErrorDocument 403 /errorpage.php?error=403
ErrorDocument 404 /errorpage.php?error=404
ErrorDocument 500 /errorpage.php?error=500

I've looked through the php.ini and can't see anything that would obviously override the Apache settings and there are no ErrorDocument directives in my httpd.conf either. Anywhere else I should be looking?

Thanks in advance.

Answer

Alexander Garden picture Alexander Garden · Aug 5, 2011

See this answer to a very similar question. Basically, PHP isn't hardly ever going to trigger a 500.