Skip to content
Fragmented Development

Avoid 404 Messages

There's nothing more shameful, nothing more embarrassing than finding that one of the links on your page is dead. If you're going for the quaint amateur-ish designer look, then let the links on your site lead to 404 errors. I can't think of any better way to lower a visitor's opinion of your competence...

...Well, maybe there is one thing that's more of a "faux-pas" — causing 404 messages for people linking to your site. If you ever expect to have a successful web site, one of the keys is not abusing people who link to you.

Inbound links are invaluable to any web page, by providing direct traffic and increasing your chances of being listed in the top search listings. So it's your duty as a web citizen to keep your site structure fairly stable, and prevent breaking any direct links to your pages. If someone has been kind enough to link to you, don't pull that page out from under them.

In a perfect world, that would be that — end of discussion. Instead, there's almost always going to be a situation where you need to move or rename a page on your web site. Luckily, there are several ways to do this without breaking links.

HTML Headers

HTML headers are sent between the browser and the server, and are a great way to redirect people to the new location of the page. When someone requests the old file, simply send them these two headers instead:

HTTP/1.1 301 Moved Permanently  
Location: newfile.html

Easy as that. Now anyone who visits the old URL will be taken to the new updated one, and anyone who cares (search engine spiders, webmasters checking their links) will know that the link in question is an old link and should be updated.

These headers can be sent from the web server software (IIS or Apache), or can be sent through scripting languages (PHP's header function).

Javascript/Meta Refresh

If you don't have access at the server level, and don't have the ability to use a scripting language, you can always use the HTML meta tag option or a short Javascript function. Just make sure to display a message to the user beforehand, to prevent confusion. This will at least get people and spiders to the appropriate file.

I would post an example here, but you can probably find a better example if you search for the term "meta/javascript refresh/redirect".

People who link to you are doing you a favor; return the favor by making sure those links always lead somewhere!

Tags: content


Add Your Comment