About The Author

I am a search marketing geek. Work as APM for one of the leading companies in UK. Interested in socializing and helping others.

Get The Latest News

Sign up to receive latest news

November 14, 2008

How to write 301 Redirects for Websites?

What is 301?

A 301 redirect is a term/process to move your domain to another domain. The 301 - redirect is referred to as a permanent redirect. It is a Search Engine Friendly method and retains your visitors and rankings without causing any harm to your ranking or website. In simple terms it directs the web traffic from one web address to another, without any intermediate web pages.

Why to redirect a web-page?
A web page may be required to be redirected due to the following,
  • The webmaster/owner wants to change the domain name of a website, or
  • The two websites which were different, have to be merged, or
  • If you have to change the names of the files or move the website's pages around.

How many ways can be used to redirect the web page?
There are few ways which can be used to redirect a web-page or a web-address permanently.

1) Meta Refresh Tag - A meta refresh tag can be placed in the source code, i.e. the HEAD section of the web-page where it looks something like,

*meta http-equiv="refresh" content="0;url=http://www.webpage.com/new.htm"*
*title*page has moved*/title*

Note: '*' represents the respective HTML tag.

This method has some drawbacks,
  • Usability Problem - If the redirects happen quickly, then the users cannot get back to the original page. Furthermore, if this refresh tag leads to a non-existent page then the users will leave the website.
  • Other Concern - Refreshing the content leads to confusion in the visitors as to where he is taken to, without being reloading the web-page.
  • SEO Point of View - This technique is used by spammers to trick the search engines, and takes visitors to other page.

2) Create an Error Page - The other method is to create an error page for the web page to be moved for. But this also has it's drawbacks,

  • Lose Ranking - You lose the ranking of the web-page of your site, and hence the traffic, and
  • Lose Visitors - It leaves a bad impact on the user to reach a web page which is leading him to no where, and sometimes it's difficult for the visitors to go and dugg the information for which there were searching for into to the other pages of the web site.

3) 301 Redirect - This is one of the most important, convenient, easy and search engine friendly method to permanently redirect your web page or a web address to a new location. The 301 redirect is implemented in the .htaccess file of the site.

.htaccess - is the default name of directory-level configuration files in the websites hosted on APACHE SERVER. The .htaccess file is placed in a directory, and the directives in the .htaccess file apply to that directory, and all subdirectories thereof. It provides the ability to customize configuration for requests to the particular directory. When the spider next visits your website, it will follow the rule as mentioned in the .htaccess file.

301 Implementation - Now here again we can consider three things,

  • Redirecting a Web-Page
  • Redirecting the Entire Web-Site
  • Redirecting Non-WWW to WWW

a) Redirecting a Web-Page

Download and/or create the .htaccess file.

Download the .htaccess file, which is in the root directory of your web site on the server where all the pages are stored, and/or create a new, if there is no .htaccess file there, create one with notepad. Save that notepad file as ".htaccess" .

Just add the following code,

redirect 301 /old/old.htm http://www.website.com/new.htm

Remember that if there are a bit of codes in the .htaccess file which you have downloaded, then don't manipulate any thing, rather scroll to the bottom and make one line space and add the above code. That's all you need to do. Save it and upload it to the root directory of the website.

Note: Don't add "http://www" to the first part of the statement - just put the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:

redirect 301 (specifies that the page has moved)

/old/old.htm (the original folder path and file name)

http://www.website.com/new.htm (new path and file name)

b) Redirecting the entire Web-Site

You can redirect the entire website using the 301 technique. Just follow the code below to redirect the old domain to a new one or to other domain,

redirect 301 / http://www.website.com/

where, the first "/" indicates that everything from the top level of the site down should be redirected.

c) Redirecting Non WWW to WWW

This in SEO is know as Canoncalization, where both the non-www and the www versions of your website are being indexed. The code below shows to direct all non-www traffic to www. Add the following to your .htaccess file.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301]

Make sure that the links to folders always end in a trailing / if there is no filename after that link.

For FrontPage users: in addition to the above, also change the .htaccess files in:

_vti_bin /_vti_adm
_vti_bin/ _vti_aut

Replace "Options None" to "Options +FollowSymLinks"

Some Useful Links

Interesting Posts

Most Read SEO Articles


Naruto Manga Spoilers said...


I have just purchased a custom domain name. My hosting is free under Blogger/blogspot.

As per GWT, i got 404 not found craw errors, and its about 483 linked pages. Can I fix this using 301 redirect? Is there a way to do it at one time only?

Please help me.
I've bookmarked this page so i could see your reply.
Thank you in advance.