2

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?

  • I think this answer can help you. – MinhTri Apr 26 '16 at 3:11
  • @Dan I have seen this post already, and am already using ErrorDocument within the .htaccess file, so this can't be right because I have no way of testing this to be sure it is working. Unless you know of a way to trigger a 500 error on a localhost machine? – Solomon Closson Apr 26 '16 at 3:15
  • Well, It's easy. Put this code in your .htaccess file RewriteRule ^])((a-zA – MinhTri Apr 26 '16 at 3:17
  • Ahh, so I am getting the original 500 Internal Server Error now, it is not using the 500.html file as it should. – Solomon Closson Apr 26 '16 at 3:20
  • 1
    Well, in the same server, WordPress will never have an opportunity to handle 500 error. Because it's server-side error which tell you that "Opps! Something prevents me from fulfilling your request". While 404 error tell you that "Hey, I have found everywhere in my server but I cannot find anything which matches your request." – MinhTri Apr 26 '16 at 4:08
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

  • I do not believe the server has ability for custom error pages. Using wp-engine, also, why is this not possible to do on localhost, running my own server? – Solomon Closson Apr 26 '16 at 3:26
  • None of those links help me to get 500 error pages working in wordpress on my localhost or on any server that I know of. Not sure what I am doing wrong here, but my .htaccess file is setup properly with ErrorDocument 500 {path to 500.html file} – Solomon Closson Apr 26 '16 at 3:38
  • "why is this not possible to do on localhost" As you notice on the screenshot: Basic error pages are automatically provided by the web server (Apache). As for localhost pay extra attention on the syntax. Here are some guidelines: httpd.apache.org/docs/2.4/custom-error.html. And for Setting Up Testing for 500-Level Errors: digitalocean.com/community/tutorials/… – marikamitsos Apr 26 '16 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.