Golden Rule on Redirects to Keep Google Happy
Let us say Joe has an old web site, but he wants to change his main domain name and the location of a few pages on his web site. There are a dozen different ways to redirect a web site, but what would be the best way to get this done? You want to use what is called a 301 redirect. Now why is this the best one to use? Well, because Google says so.
To do the 301 redirect for your main domain name, you can copy/paste this code into your .htaccess file (if you are on an Apache-based server):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*youroldwebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.yournewwebsite.com/$1 [R=301,L]
To simple redirect a single page, you can copy and paste this code into your .htaccess file:
Redirect 301 /old.html http://www.exampledomain.com/new.html
Of course, please remember to change the example names and file paths to meet your own needs. For more help on rewriting address locations, check our the URL Rewriting Guide on Apache.org.


March 13th, 2009 at 3:10 pm
True, im using the second code but not only for redirects, also for masking the affiliate links I have, since google is not a big fan of affiliates links now adays.