custom 404 page

9 Feb
2010

A big problem when a site starts to get rather large, or you run pages from product feeds, or you decide to restructure… any of the above and more, is that at times, pages in your site might have a URL change, but still either have incoming links from other sites, or still appear in the search engines (perhaps for some strange long-tail search phrase, but none-the-less, it may still appear).

What can be extremely handy in that situation is a custom 404 Error (page not found) page. Rather than potential customers getting a blank screen, or a message from google/bing (other search engines available) saying the page doesn’t exist, it’s far better to give people the page you want should that happen – maybe with your normal headers and menus, but a nice message informing them the page doesn’t exist, but they can browse  the site for an alternative product!

What is even better about this idea, is it is simply one line of code in your .htaccess file, which for starters will be in the same root directory as your home page, or alternatively you can have a separate one for each directory of your site.

So – first go write your 404 error page, name it something sensible (eg something-sensible.html), then edit your .htaccess file to add this line of code at the end:

ErrorDocument 404 http://www.monthly5k.co.uk/something-sensible.html

of course, if you’re using wordpress or joomla or some other well developed sort of content management system, this will be done for you as part of the system,  but for many smaller specialist systems (some shopping carts, affiliate store packages, etc) you’ll probably need to create your page through the system itsself, and use that new pages URL as the one above.

Comment Form

top