How to add a custom 500 server error page?

It seems easy to create a custom error page in Wordpress for a bad page, i.e. 404 not found - just create 404.php in the themes directory.

I would like to do the same for a server error, let's say if the CGI script on my Wordpress site does something stupid, like divide by 0.

I tried to create a 500.php page in my themes directory, but it seems to be ignoring it. Instead, the 404.php page in the theme directory is called.

It seems that Wordpress somehow catches the server error and translates it into an "not found" error, and then uses 404.php

How to make Wordpress go to another custom page in case of a server error (500), as opposed to a simple error not found (404)?

And before you tell me to add something like ErrorDocument 500 / path-to-custom-error-page to the .htaccess file, already tried this - it is ignored by the web server, probably because the RewriteRule directives in the same file are used Wordpress to intercept and process all requests (and it doesn’t matter if the ErrorDocument directive is specified above or below the Wordpress RewriteRule section).

(Note: I tried to study this myself, but the search results are polluted by people complaining about getting server errors in Wordpress without asking how to create a custom page to handle them.)

+5
source share
3 answers

WordPress (500). .html PHP WordPress. -, , , , -.

+4

WP 3.0 , wp_die() , wp_die_handler.

'wp_die' 'wp_die_handler' wp-includes/functions.php.

+2

ErrorDocument 500 …should work in any case , if the path is correct. Disable WordPress rewrite rules, create a 500 error, and Apache should either show /path-to-custom-error-pageor say that it cannot find it.

0
source

All Articles