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.)
source
share