Posted on Saturday 17 February 2007

301 redirect aka “moved permanently” - definition

A 301 redirect is a server side, search engine friendly way to lead surfers as well as search engine robots to the new location of a webpage or a whole website. The 301 redirect tells the search engine robots that the corresponding webpage has permanently moved somewhere else.

Implementation of a 301 redirect

A 301 redirect command is typically inserted into a .htaccess file on the website’s root directory, similar to mod_rewrite url rewrite directives. It’s a simple file in regular text format named .htaccess, pay attention to the dot at the beginning. Usually files are named like “name.extension”, this file is different though - from a technical point of view the file could be considered unnamed and having the extension “htaccess”.

Here’s this server’s htaccess file as seen from the ftp software:

htaccess file in root folder

Creation of a htaccess file

Due to the fact that on Windows it’s not possible to create a file without a file name, you should create a usual .txt file from any notepad/wordpad/word kind of software.

If you want to redirect just a few webpages, here’s a simple way on how to code it for either files, folders or whole domains.

The general 301 redirect syntax is:

redirect 301 /source target

Redirect a whole website to a specified target webpage

redirect 301 / http://www.target-webpage.com

Redirect a specified folder to a specified target webpage

 redirect 301 /folder http://www.target-webpage.com

Redirect a specified file to a specified file on the target webpage

redirect 301 /folder/file.html http://www.target-webpage.com/example.html

If your redirection needs are more complicated, use regular expressions (regexp):

Redirect all html files to php files with the same file name on the target url

RedirectMatch 301 (.*).html$ http://www.target-webpage.com$1.php

This works the same with other usual webpage file types. Please note that the target webpage can also be the same domain, as it is in most cases for file extension rewrite directives.
This for example is the content of the htaccess file currently in use for this website (click to enlarge):
301 redirect in a htaccess file

As you can see, I have faded out the unimportant part of the content. The 301 redirects I have currently implemented are due to a change in category for two articles.

Advantages of a 301 redirect over other redirections methods

A 301 redirect is a server-side redirect, unlike other redirection methods such as meta refresh. If you should ever have to move webpages or whole websites to another location, you should definately use a 301 redirect. All other redirection methods are inferior, because they are either not cross-browser compatible or do not preserve your Search Engine Rankings. You don’t want to loose your Google PR and general Search Engine power you have built up over time. Google PR for example is actually passed on to the 301 target, which takes a while to complete, usually a couple of weeks. After that time, from a Search Engine point of view, the full power of the old page is given to the new page.


2 Comments for '301 redirecting is search engine friendly'

  1.  
    February 19, 2007 | 1:42 pm
     

    […] 301 redirecting is search engine friendly […]

  2.  
    May 2, 2007 | 3:58 am
     

    informative post. While you have covered the basics of 301 redirection using .htaccess and mod_rewrite, I have created a guide to 301 redirection - URL redirection in ASP, PHP, .Net and JSP/Java for people who are using different technologies and also those who would like to do it even on a page level without working on the .htaccess.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI