301 Redirect PR Leak Fix
by Matt on , under Web Development
Since Google sees www.takemorerisks.com and takemorerisks.com as two seperate entities, I decided it was time to take action and correct the current PR leak by redirecting all takemorerisks.com requests to www.takemorerisks.com.
It’s interesting to see that takemorerisks.com is a PR2. If I left things as they are it’s possible that this value could increase – making it the difference between my blog achieving a PR4 and PR5. Or even worse…
To correct the problem I added the following lines to my .htaccess file
RewriteCond %{HTTP_HOST} !^www.takemorerisks.com$ [NC]
RewriteRule ^(.*)$ http://www.takemorerisks.com/$1 [L,R=301]
Now if you type http://takemorerisks.com you’ll be automatically redirected to http://www.takemorerisks.com If I wanted http://www.takemorerisks.com to redirect to http://takemorerisks.com I’d have used this.
RewriteCond %{HTTP_HOST} !^takemorerisks.com$ [NC]
RewriteRule ^(.*)$ http://takemorerisks.com/$1 [L,R=301]
It’s important to decide whether to use www. or not when you first start your site as it will prevent any of the problems I’ve outlined here. Google SEO expert Matt Cutts delves into greater detail in his SEO advice: Url Canonicalization post.
Update
If you’re using Wordpress and want domain.com/file.html to translate to www.domain.com/file.html you must position this code before the “RewriteRule . /index.php [L]” rule in the .htaccess otherwise visitors will be redirected to www.domain.com/index.php each time.
Here’s what my .htaccess looks like now.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /# BEGIN re-direct code
RewriteCond %{HTTP_HOST} !^www.takemorerisks.com$ [NC]
RewriteRule ^(.*)$ http://www.takemorerisks.com/$1 [L,R=301]# END re-direct code
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</IfModule>
# END WordPress


March 9th, 2007 on 12:02 pm
Great post! Very useful!
March 11th, 2007 on 10:34 pm
Just did this myself recently after finding I was PR4 for one and PR2 for the WWW. version.
A waste of good pagerank!
May 16th, 2007 on 12:47 am
[...] of blog URL’s; 301 redirects etc. I’ve found excellent resources through Matt at Take More Risks; Matt Cutts at Gadgets, Google and SEO as well as Nate at NateWhitehill dot [...]