Create A Custom 404 Error Page

One of the easiest and most common ways to use status codes to your advantage is to enhance your website by creating a custom error pages. A custom 404 page is often used as this presents an opportunity to retain a user despite a missing page or broken link, but it's quite possible to create custom pages for most of the http statues.

The idea is to simply display a useful web page that is in the same style as your site instead of the standard error page.

Please also see our information about creating a perfect 404 page.

If you are using Apache:

  1. Create your custom 404 page and give it a name like page-not-found.html.
  2. Create a file called '.htaccess' (that's a file with no name and a '.htaccess' file extension) in the root of your site.
  3. Enter the line: ErrorDocument 404 /page-not-found.html in your htaccess file.
  4. Upload the page-not-found.html and .htaccess files

If you are using Windows (IIS):

  1. Create your custom 404 page and give it a name like page-not-found.html.
  2. Locate the properties for the WWW service.
  3. Select the 'Custom Errors' tab.
  4. Replace the default document for the 404 error with page-not-found.html.

Important: Check that your website is still returning the correct 404 status when a page is not found. For this you can use our HTTP Status Checker.

If your custom 404 page is not returning a 404 then you need to correct this. The most likely cause is that you are redirecting the user to a valid location instead of issuing a 404 and displaying your custom page. For example, if you have the full url in your htaccess file like this: "ErrorDocument 404" this will actually cause a redirect to the absolute location. Remove the absolute URL and just use the page name like this: "ErrorDocument 404 /page-not-found.html" this will not cause a redirect it will simply issue the 404 and display the page indicated.

This is important so that spiders and web crawlers realize that this is an error page and not a normal web page.

For ideas about how to create a perfect 404 page click here.

There is some good information about handling 404 errors from Google here.