Redirects - the good, the bad and the ugly

Redirects are an important part of a well maintained site. As pages are deleted or moved, it's common courtesy to sent the visitor to the new page, or at least apologise for the inconvenience.

Types of redirect

Redirects come in several flavours. Redirects can be done by the server, or by the client (browser). Generally speaking, a server redirect is more reliable and seamless, so is usually recommended.

Server side redirects are done by using a scripting language, such as PHP or ASP. They can also be done by the web server, usually Apache or IIS. Server redirects can be done as a 301 (permanent) or 302 (temporary) HTTP header.
By default, redirects are usually done using the 302 header, which is not usually the preferred method.

Client side methods include a META redirect, where a META tag specifies the location of the redirect and the delay. The delay can be used to inform the visitor that the page has moved, which is sometimes useful. Most visitors don't care if your content has moved or not, and would rather be redirected to the new content without being told about it.
The other common client side method is using Javascript. There are a number of ways to implement redirects in Javascript, the obvious downside being that Javascript support is required for the redirect to work.

Checking redirects

Client side redirects can be detected by viewing the source code. META redirects will look similar to the following code...
<meta http-equiv="Refresh" content="10;url=">

The above page will redirect after 10 seconds, specified in the content attribute.
Server side redirects are a little more subtle, and you need to inspect the HTTP headers to see if the redirect is a 301 or a 302. For Windows users Microsoft Fiddler is an excellent tool for this for.
  • Download Fiddler from
  • Run Fiddler
  • Open the page you want to inspect in Internet Explorer
  • Fiddler will tract each HTTP request. Watch for the response code on the page you are inspecting. 301 = permanent redirect, 302 = temporary redirect, 200 = no redirect or client side redirect.

Fiddler will not inspect any web traffic from Firefox (and perhaps Opera), you must use IE. I would assume this is a "feature" rather than a "bug"...

It appears my subtle microsoft bash was a little unfair - a reader has just emailed in the following...
Fiddler operates with *any* browswer that uses its proxy. IE automatically picks up the proxy, whereas Firefox doesn't. I believe Opera only does if Fiddler has set itself up before Opera is launched (not completely sure about this). You can easily set Firefox to go through fiddler in the proxy setup, and optionally use a FF plugin for easy proxy switching (eg SwitchProxy).

Thanks for that - having Fiddler work in FF will come in handy.

Moving pages

The most common reason for redirecting is when a page moves to a new address. In this instance, a 301 server redirect should be used as this tells the search engines to remove the old page from the index and index the new page instead.

Important: Some search engines will ignore 302 redirects, and may penalise for client side redirects.

Removing pages

When a page is deleted, it's polite to gracefully inform the visitor, who may have just arrived from a search engine or broken link on another site.

By default, the web server will issue a 404 or page not found error. Well maintained websites will have a customised and friendly 404 message, with a link back to the homepage, and an explanation as to how the error might have occured. This is much better than the default "this page cannot be displayed" message, which usually has visitors reaching for the back button.

With a customised 404 page, you have some chance of keeping the visitor.
Digg StumbleUpon technorati blinklist furl reddit sphinn

Tags: 301301 redirect302302 redirectphpredirectredirectionurl301 "301 redirect" 302 "302 redirect" php redirect redirection url