Saturday, October 5, 2013

Making A Custom Page Not Found

You worked hard to get traffic to your website so the last thing you want is to lose visitors because a webpage they requested cannot be found, either because it has been moved, deleted, renamed, or the url was mistyped.

Such incidents happen quite often and when they do visitors are greeted with the standard "page cannot be found" message browsers display when the website doesn't have a custom error page to deal with such situations.

Custom error pages will help you retain those visitors by directing them to other parts of your website through links on the error page. And you know what? Making a custom error page is quite easy to do as you are about to see. The only requirement is that your site needs to be located on a paid web hosts since most free hosts don't allow custom error pages.

The error page requires two files, one is the error page which is a regular HTML webpage that contains any information and links you want to put into it. You can name it anything you like such as oops.html

The other file is a .htaccess file. This file tells the web server to show the error page you made when folks encounter a webpage that doesn't exist.The .htaccess file is made in any standard word processor such as Notepad. So open a blank file and add the following code:

ErrorDocument 404

It should be on one line, replace with the entire url leading to your error page. Save the file by naming it .htaccess  including the dot preceding it. 

Upload both files to the public_html directory (where index.html is located). When your .htaccess file was created the word processor most likely attached an extention so that it looks like this:


The .txt extension needs to be removed by renaming the file within the ftp program or the file manager in your cpanel . That's it now test you error page by entering a non existent page in your site url within the browser's address bar. If you get your customized error page mission has been accomplished.

NOTE  Some web hosts include the .htaccess file in your account, if you see it simply open and edit it so that ErrorDocument 404 points to your custom error page.