Link redirection

The location of documents and web pages can change. It’s a simple fact of life in the life of web developers. So how do you ensure that when a document has moved to a new address it can still be accessed?

1. Change the links from the old address to the new address
This seems evident but it’s not always done. Why? because it’s tedious and not always accurate. How can you be sure you haven’t missed a link?

2. Do a server redirect
The webserver can include an HTTP 301 response header pointing the browser to the new address. This can be achieved in a number of ways through server configuration files, .htaccess for example.

3. Script a redirection
If after all that people are still accessing the old document, let them know it has moved permanently at the old address. This can be done through a simple document:

We’ve moved!

function redirect(){

We’ve moved!

This page has moved to a new location:
Please update your bookmarks and update your links.

The first step in the document is the meta header equivalent. It will force your browser to update the location after a period of time. I normally go for 4 seconds. Anything quicker and the user has not had a chance to the read the content of the page and would not appreciate the “flicker” effect. 5 seconds or more and it feels like nothing happens and the user may decide to click the link out of boredom.

The second step in the Javascript. If the document meta header is ignored by the browser, javascript can start the redirection after a period of time. Again, 4 seconds is about right.

The third step is the text and the link letting the user know what’s going on and where they should go, in a polite way. This is useful if Javascript is disabled.