views:

309

answers:

2

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.

A: 

I don't believe Apache will let you run PHP files for 500 errors because the error page could generate an error. Try rendering out your 500 error to an HTML file and point your directives at that.

mattbasta
Thanks for the suggestion but using a .html file makes no difference, the browser still receives a 500 response and no content.
Jason
A: 

You may need to add the ErrorDocument declaration earlier in the Apache conf chain. If you add this to a vhost conf it may not be called.

jakemcgraw