Custom 404 (Page Not Found) Messages
Posted by Clarke M on 03 April 2006 07:42 PM
I was going to type out instructions to create a custom 404 page, but I found instructions on the net that are brief, clear, and very well laid out. So - Clarke's gonna cheat this week. I think my hands are still tired from the "how to switch to Firefox" novel.

Here you go:

If you have your own domain name, you can create a custom 404 error page for your visitors. What does this do for you? It can help you retain visitors who may leave if they get the standard "File not found" page. Such a page looks a little like this:


File Not Found

The requested url /notafile.htm was not found on this server.

That isn't very appealing to a visitor, and if the person came from another site's link- that potential visitor may just leave. However, you can make your 404 page much more informative, and provide your visitors with a way to navigate through your site. Instead of a "File Not Found" and not much else, you can send them an error page with a professional appearance.

As an example, click the link below. This will take you to the custom 404 page for this site (The author's site):

Custom 404 Example

Notice how the page was similar to the other entry pages on the site, with the navigation links and a way back to the front page. This allows the visitor to take a look around, or go to the front page where they can see the details of what the site has to offer.

Now, the creation of the custom page itself isn't difficult. It is just another HTML file saved with any name you want it to have. To get your custom page to show up on a 404 error requires a little extra work. You will also need to be the one in charge of your web site, and it must be under your own domain name. You will not be able to do this otherwise, because someone else will be in charge of the domain. If you are unsure whether or not you have permission to do this, be sure to ask your web host before you proceed.

To begin, go to the main directory of your web site (where your main page is located) through FTP or Telnet. Look for a file there named .htaccess, it begins with the dot as though it is a long file extension. If you have the file, you will want to edit it. If you do not have the file, create a new text file and save it as ".htaccess".

(Note from Clarke: You will not be able to create a file called .htaccess on a Windows machine. Create it without the dot instead, and change the name after you upload it.)

If you are creating the file from scratch, simply type the following line into the file, changing the url to the location of your custom page:

ErrorDocument 404

Keep it all on one line, with a space on each side of the number 404. Also, this is case sensitive, so be sure to check the case of the E and D in ErrorDocument before you proceed.

If you already have the file and need to edit it, look for a line like the one above. If it is there, you can just change the url. You may want to ask your web host before doing this, just in case. If you do not have the line, add it in after everything else on its own line.

When you are done, upload your new .htaccess file to the server. Then, be sure to use the CHMOD command through your FTP or telnet program to set the permissions to CHMOD 644.

Also be sure that you have uploaded your custom page to the server, otherwise you'll get a 500 server error or something similar. Once that is done, you can test your new error page by typing in a url that you know does not exist on your server. You should get your custom page, ready to bring in the lost visitors that may be out there.

Article Copyright © 1999 by John Pollock
Original page:
(524 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Help Desk Software by Kayako Fusion