Easily make sexy error messages in WordPress (and everything else)

This page may contain links from our sponsors. Here’s how we make money.

Some hosts have custom error page options in their admin panel software, but if you want to bypass that and easily make your custom error messages work (as long as you're running Apache) it's pretty simple. Especially if your a blogger, and you're familiar with .htaccess files, this is a very simple process and it works great. Let's get started.

Easily make sexy error messages in WordPress (and everything else)


Part 1 – General

Step 1

Design your error page as a static HTML page.

Step 2

You can upload the error pages to anywhere on you server, but I recommend putting them either in the root directory, or in a folder in the root.I put mine in a folder in the root called “errors.”

Step 3

Add the following line of code to your .htaccess file in the root of your site.

ErrorDocument 404 /errors/404.html

And for the other error messages, simply uplad the other HTML files and add another line in your .htaccess file and change the error code to whatever you need, like:

ErrorDocument 503 /errors/503.html

in my example code, obviously, I've got a folder called “errors” in the root directory of my blog, and I named my error message html files as the same name as the error I want to display.

And that's it. If you are having trouble seeing your error messages, you might check your file paths in your .htaccess file, as well as the file paths to images in your HTML and/or CSS, depending on how you have it setup.

Part 2 – Custom 503 “Service Unavailable” Page using WordPress and the Maintenance Mode Plugin

Step 1

Obviously, have the Maintenance Mode plugin installed and activated. Maintenance Mode lets you display a custom message while your site is down, whether your upgrading, or making a new theme, or simply doing maintenance of any kind. Nowadays, wordpress shows an error 503 (most likely your server default) “Service Unavailable” error when you do an automatic upgrade, so customizing this 503 error can make you rest a little easier when you need to upgrade your worpdress. (which wordpress users know, happens often.)

Step 2

Copy your 503.html error you already made in Part 1, and put it in your wordpress theme directory. Then rename it to 503.php. Even though it's most likely a simple html or xhtml file, the Maintenance Mode plugin needs a “php file extension, and it has to be in the same folder as all of your theme files. (don't forget to move any images, and check image URLS during this process, as well as any image URLs in your CSS for your 503.)

Step 3

In the WordPress Dashboard, go to Settings > Maintenance Mode and select the custom 503.php option under “Splash Page Theme.”

Splash Page Theme

Done

In order to test the custom 503 that will display when you do upgrades (as long as maintenance mode is active before you upgrade) you can just activate it for a minute to see what it looks like, but you have to either log out, or use a different browser where you aren't logged in to your site.

Conclusion

Custom error messages can be cool, and I recently learned a little about how to make them, so I thought I would spread the knowledge. It was way easier than I previously thought, and all you need is FTP. As I mentioned earlier, some customizations may be available from your host admin panel, but using the .htacess method, you can add as many as you want, and therefore have more control.

Here's a link to the most common Apache Error Codes»

Here's a link to all Apache Error Codes »