BLB
BLB

Reputation: 23

Apache ErrorDocument 500

In my VirtualHost I setup default error pages.

Example:

<VirtualHost *:80>
        ServerName example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /var/www/html/>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorDocument 403 /error_page/403.php
        ErrorDocument 404 /error_page/404.php
        ErrorDocument 500 /error_page/500.php
        ErrorDocument 503 /error_page/503.php
</VirtualHost>

Error 403 and 404 seems to work but error 500 doesn't. As a test I require a php file that i know doesn't exists:

require ("unknown_file.php");

In Safari the page stays blank and in Chrome or Edge I get the default Error 500 page. I can set display_errors in PHP to On but that i do not get the custom 500 page but the error message which I don't want in production.

What am I doing wrong? I have restarted apache and PHP but that didn't make any difference.

Upvotes: 0

Views: 216

Answers (1)

Daniele Continenza
Daniele Continenza

Reputation: 92

Error 500 is for a (temporary?) server error.
If you want to simulate it, just put this in a php file (eg: test_error_500_page.php)

header('something', true, 500);

Now calling www.yoursite.com/test_error_500_page.php you'll get the "/error_page/500.php" page contents

Upvotes: 0

Related Questions