Apache does not want to display a custom error document that I have setup.
In my vhost I have
DocumentRoot /var/www/site/public
...
ErrorDocument 500 /500.html
The 500.html is located in /var/www/site/public/500.html
To test this I have just created a broken php page that does return a 500 header but the page is blank. I suspect that this is a result of php generating the 500 page and not apache. So how do I get php to show my custom apache error document?
Best Answer
This is normal behavior, as PHP errors aren't considered 5xx Server Errors. According to RFC 7231
PHP errors should always be fixed as they may pose you security problems. For the same reason best practise in handling php errors is to log them for the programmers to review and hide them from users. This kind of setup would be (in php.ini format):
This will log errors in web server's error log or in other error log configured. Instead of reading them from the site you can perform
tail -f
on the log file during loading the page.