How to get a Custom 500 Error Page to show?

I created a 500.html file and would like to get this page loaded for my wordpress site. I’m running on XAMP localhost for now, but I’ve never done this sort of thing before and would like to be able to get it working on my localhost first to be sure it will work on the live server, when deployed.

So far I have tried the following in my .htaccess file:

ErrorDocument 500 http://localhost/500.html

But this does not work and does not show the 500.html file when I do this in my header.php file custom wordpress theme (at the very top):

throw new Exception('Nooooooooooooooo!');

I figure this should throw a 500 error, but all I get is a blank page. I also tried putting the 500.html file within the themes root folder, and link to that, but no luck. Currently, this is what is in my .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^^members/([^/]*)/([^/]*)/? /^members/$matches[1]/?$matches[2] [QSA,L]
RewriteRule ^^/([^/]*)/([^/]*)/? /^/$matches[1]/?$matches[2] [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
ErrorDocument 500 http://localhost/500.html

Does wordpress have any built-in settings for doing this? If there is something I need to put into my .htaccess file, where do I put it at?

1 Answer
1

Does wordpress have any built-in settings for doing this?

Most likely your host will have an option on your cPanel for custom Error pages. Something along the lines of:

Custom error pages

If that is not the case, please have a look at this older question:
How to create custom 401, 403 and 500 error pages?

EDIT 1:
Also at this one: https://stackoverflow.com/questions/12184402/wordpress-how-to-add-a-custom-500-server-error-page

EDIT 2:
You can also try this Gist as an alternative. Instead of using the .htaccess file, you can place the code in your functions.php

Leave a Comment