301 and 302 Web Page Redirects

301 and 302 Web Page Redirects

By Alex Skorohodov

Redirection – From an Old page To a New page

What exactly is a redirect, and how do they function?

Why do web page url’s change? Site owners change their domain names, will restructure their web sites or launch a new way of delivering, and these are just some of dozens of reasons that url’s can change.

If you change the name of your URL, your site visitors and search engines will also have difficulties finding the new page. If your page was indexed with a high ranking then how are people going to locate it? Redirection is one solution. With redirection, site owners can have the ability to send a request to the search engines letting them and visitors know where the new page is locate d.

Server-Side Redirection

This is where your web server does all the work of pointing from one place to another.

When servers complete a redirection, the server will send out an update code about the request in which it processed. When you run into a code called "404 Not Found" error, that’s a type of update code a server will send, which results in the showing of that "404 Not Found" web page.

The two type of codes that go out regarding redirection are 301 and 302 redirects. These numbers you may have run across or heard of regarding redirection and hijacking situations.

Use this code For 301 redirecting in PHP:

Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com” );

301 Redirect in HTACCESS:

  • Moving a page:
    RedirectPermanent /old-file-name.html http://www.new-domain.com/new-directory/new-file-name.html
  • Moving a directory:
    RedirectPermanent /old-directory http://www.new-domain.com/new-directory/
  • Moving an entire site:
    RedirectPermanent / http://www.new-domain.com/

A 301 ASP Redirect:

<%@ Language=VBScript %>
<%Response.Status=”301 – Moved Permanently” Response.AddHeader “Location”, ” http://www.newsite-url.com”

302 Temporary Redirect (not recommended)

The 302 ‘temporary redirect’ guidelines from W3C, state that 302’s are used when a page has been ‘temporarily’ moved to a new location on the web or within the site and but the site owner still wants visitors and search engines to keep the old site address rather than making note of the new one.

In other words, say one day kosmossupersite.com gets Slash-dotted or receives very heavy traffic, way too much to keep serving up things as normal. So, you decide to temporarily send people off to a mirror site, mirror.kosmossupersite.com. You want people and search engines to reach the new location but not record the address as a permanent change. You’d do a 302 temporary redirect like this:

Kosmossupersite.com — 302 Temporary Redirect —> mirror.kosmossupersite.com

Do that, and it’s the site doing the pointing whose URL should be retained for use in search listings. This though is not recommended because this is a common spam practice and search engines will potentially black list a site or at least penalize those pages for performing any type of temporary redirect.

Use this code for 302 redirecting in PHP


header("Location: http://www.domain.com/temporary-address/temporary-file-name.html");

302 Redirect in HTACCESS:

  • Redirecting a page:
    Redirect /file-name.html http://www.domain.com/temporary-directory/temporary-file-name.html
  • Redirecting a directory:
    Redirect /directory http://www.domain.com/temporary-directory/
  • Redirecting an entire site:
    Redirect / http://www.temporary-domain.com/

Try to avoid a 302 redirect on your site if you can (unless it truly is only a temporary redirect), and never use them as some form of click tracking for your outgoing links, as they can result in a “website hijacking” under some circumstances.

404 Page Not Found:

Search engines prefer 301 redirects when a page or site has been moved. If your removing a page permanently they would prefer a 404 Page Not found error.


header ( "HTTP/1.0 404 Not Found" );

Meta Tag Refresh Page Redirects (not recommended)

Meta tag redirection is a page-based method of pointing from one place to another. In other words, it’s something you put on the actual web page. For example:

The below code would have to be placed within your Meta Tags of your old page.

< META http-equiv="refresh" content="5;URL=http://www.kosmoscentral.com/seo-articles/reciprocal-Links-Management.html">

What you’re telling a search engine is that the new page will load automatically in 5 seconds, because the old page is forwarding to the new location. Just copy and paste the code in and change the time frame from 5 seconds to what every you wish and the destination url.

When placing redirects on old pages, we also recommend you tell your visitors exactly what is going on. For example:

“This page has moved and you’ll be redirected to the new location in 5 seconds”

Since 301 Redirects are preferred by search engines we highly advice against meta tag refresh redirecting.

Hope this all makes sense, if you’d like to comment on this article please do so within our forum and state the article title.