Configure Custom Error Pages on Apache with htaccess

Last updated on October 18th, 2014 by Robert Abela. Filed under WordPress Tips

Having user friendly custom error pages for your website is perhaps as important as having good content. Branding the broken links, restricted areas and application error pages can deliver a better customer experience and will give your website a more professional look.

You can also take advantage and use custom error pages as a marketing asset. If you brand your website’s error pages, once a user encounters one of these custom error pages he or she still has a number of navigation options into your website rather than navigating away. All the links of your WordPress website header, footer and sidebar will still be visible. You can also for example implement search functionality for the visitors to use, rather than losing the visitor. In this article we will explain how to configure custom error pages for your WordPress blog or website running on Apache.

New to htaccess? Check the Definitive Guide to htaccess and WordPress!

Website Error Pages

There are several error pages that a visitor might encounter while browsing a website. Though the most common error pages typically encountered are:

404 – This error page shows up when the visitor tries to access a page or website object which no longer exist. This could be a result of a broken link on your website or could also be an old page which some other website or a search engine is still linking to.

403 – This error page is used when a visitor tries to access content which is forbidden to the public, e.g. a user tries to access the wp-config.php file.

500 – When something goes wrong with the website, the web server returns an HTTP status code 500, which is an Internal Server Error.

Configure custom error pages with htaccess

If you host your own WordPress blog or website, you can use the .htaccess file in the root of your WordPress installation to configure user friendly custom error pages. Once you have prepared your pages and uploaded them to your server, simply add the below syntax to the .htaccess file in the root of your WordPress website or blog.

#Specify the path or name of the error page instead of notfound.php
ErrorDocument 404 /notfound.php
#Specify the path or name of the error page instead of forbidden.php
ErrorDocument 403 /forbidden.php
#Specify the path or name of the error page instead of error.php
ErrorDocument 500 /error.php

WordPress Hosting, Firewall and Backup

WP White Security is hosted on A2 Hosting, protected with BBQ:Block Bad Queries Firewall and backed up with BlogVault online WordPress backup service

Leave a Reply

Your email address will not be published. Required fields are marked *