URL Redirection Types

There are two broad types of redirects:

  • Specified in the HTTP header response
  • Specified in the HTML output

HTTP Redirects

The most common and most useful type of redirect is a HTTP status code specified in the HTTP header.

There are three main types of HTTP redirects:

301 Moved Permanently

This is known as a permanent redirect and is used to indicate to search engines that the originating URL has permanently moved to a new URL.

From an SEO perspective, link juice is passed via a 301 redirect.

302 Found

A 302 redirect was originally used for temporary redirects (in the HTTP 1.0 specifications). However, a lot of browsers implemented it incorrectly with the same functionality of what a 303 redirect now provides (which was added as part of the HTTP 1.1 specification).

It is still used extensively for temporary redirects, but a 303 or 307 redirect should be used instead.

307 Temporary Redirect

A 307 temporary redirect was added as part of the HTTP 1.1. It works how a 302 redirect was originally intended and should be used instead of 302 redirects.

Both 302 and 307 redirects do not pass link juice to the new location.

HTTP Header Redirection Examples

If we make a request to http://google.com it will send back a 301 permanent redirect to http://www.google.com

The HTTP header response will be something like:

HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 26 Sep 2012 00:21:18 GMT
Expires: Fri, 26 Oct 2012 00:21:18 GMT

and the HTML output is:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

It is the Location: response that tells the browser where to redirect to.

HTML Redirects

Apart from HTTP redirects, there are three main methods of performing redirects within the HTML source.

Meta Refresh

This is a special meta tag contained with the head section of the HTML source, which looks like:

<meta http-equiv="Refresh" content="0; url=http://www.example.com/" />

The number indicates the how many seconds to wait before redirecting to the new URL. If this is set to 0, it means redirect immediately.

There is some contradictory information as to how meta refreshes are treated by search engines, but the common understanding is that if the refresh time in 0, it is treated as a 301 permanent redirect and a refresh time of greater than 0 (or sometimes more than 5 seconds) is treated as a 302 or 307 temporary redirect.

Javascript Redirects

Redirects can also be defined using Javascript, eg:

window.location='http://example.com'

However, Javascript Redirects are not reliable as some browsers may have Javascript disabled and most search engines won't follow Javascript redirects.

Iframe/Frameset Redirects

This is a method where the content of another page is shown within an iframe or frameset, so that it looks like the content is part of the original URL.

Commonly this method is used for cloaking links and is considered to be a BlackHat technique.