Adding a 404 page to your website

Keith Curreri - Blog Headshot

By Keith Curreri on August 26, 2010

How often do you run into an error page on a website that look like these? (Click on the thumbnails to enlarge)

These pages are called 404 error pages. A 404 error is when a page that you are trying to access on a website is not found. A lot of internet users do not know what a 404 error is or what to do about it. To them, it is just another unintelligible error message from the computer.

Now, what do you do when you do land on one of these pages? Actually, there is not much that you can do. You can click the BACK button and go back to where you came from or try emailing the webmaster, but other than that the default error pages are not very helpful.

Making a 404 page with .htaccess

If your web server supports .htaccess then this will be the optimal method for creating a 404 page. This only applies to a website hosted with a Linux OS.

Step 1: Create your error document file

A 404 page is just like any other page in your website. It can be in .html, .php, or in any other web language file extention. Just create a new webpage and name it something like “error-document.html”. Put it in your website’s root folder.

See my post, What makes a great 404 page? for ideas on what to put in your 404 page for it to be most effective.

Step 2: Create the .htaccess file

  1. Check and see if your site has an .htaccess file in the root directory. If it doesn’t, create a new file in the root directory and name it “.htaccess” (note the preceding period).
  2. Add the following line of code anywhere in your .htaccess file. Change “/name-of-error-document.html” to the path of your document.
ErrorDocument 404 /name-of-error-document.html

Step 3: Testing the 404 page

When you have completed steps 1 and 2 you should test your error page to make sure that you set everything up correctly.

Manually type a web address in your URL bar to a page on your site that you know does not exist. If your 404 page pops up, you installed it correctly!

Making a 404 page with a Windows/IIS server

Windows servers are a little bit more tricky as they do not support .htaccess. You can still create a 404 error page, but you will have to contact your website hosting provider to get specific directions because each hosting provider’s set up system is different.

Why should a website have a 404 page?

Most likely your website visitors will not see your 404 page. Inevitably a few of your visitors will see it, which is why it is important.

The default 404 page is not very helpful when a visitor runs into a dead link. A proper 404 page should provide some resources so the visitor visits another page and doesn’t just leave the site.

Conclusion

A 404 page is an important feature to any website. It helps you to keep visitors on your site as well as adds a special extra detail to your site which will set it apart from others.

Leave a Reply

2 Comments on "Adding a 404 page to your website"

Notify of
avatar
Mitch

You know, I created a 404 page for my main business site many years ago, and promptly forgot how to do it. Thanks for the reminder; I need to go back and create one of these for all my other websites. I don’t think I have to do it for my blog though.

Keith

Glad I could remind you. Some WordPress themes have a built in 404 page, so depending on which theme you are using you may not have to worry about it.

wpDiscuz