This tip only applies if you own your own domain name, and can access your server.
If you own your own domain like http://www.blog-op.com, you may have noticed that you can type in http://blog-op.com and end up at the same place. This is because the addresses are essentially the same, and the www is actually superfluous. So what?
Well, if someone links to your www address, and then someone else links to your non-www address, then Google (and others) don’t treat them as 2 links to the same site, but rather links to two completely different sites. This obviously has implications for calculating page rank, as both versions of your address may have their own pagerank, neither of which are as high as they should be.
This was brought home to me when I used the useful Smart PageRank tool (Thanks Tricia) and it showed that Blog-Op had a page rank of 2 for the www address, and 4 for the non-www address. Now, combining the two won’t mean I get a pagerank of 6, but you need a reasonable number of links to get a PR of 2, and these really should be going towards making my non-www address get a PR of 5.
How to fix it? Easy; log on to your server with an FTP program and find the .htaccess file in the root directory. Download it, open it with WordPad or NotePad, and then insert the following code into the file after whatever else is in there, but before the ‘# END WordPress’ tag at the end.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.YOURDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [R=301,L]
Obviously substitute the ‘YOURDOMAIN’ for your address, and be careful not to disturb the backslashes which are correct. Save the changes and upload it back to the server. This will now redirect everyone and every Google bot who looks for www.YOURDOMAIN.com to the non-www address without them even noticing, and ensure that ALL of your inbound links count towards your pagerank score. It’s easy and takes less than a minute to do, but as ever make a copy of your .htaccess file before making any changes.
Thanks for the code to, and more information on the matter at: no-www.org.





15 users commented in " How To Do A 301 Redirect - And Why You Should "
Follow-up comment rss or Leave a TrackbackI’ve been using Justin Shattuck’s WWW-Redirect Plugin to do the same thing.. not sure if it has the same effect as the 301 redirect by htaccess.
BTW, If I want to redirect my domain to http://www.yourdomain.com, do I insert http://www.yourdomain.com instead of http://yourdomain.com?
It was actually reading Justins page that led me to this - he said he prefers the .htaccess route and linked to the no-www website (I think-I surf so many sites I lose track…)
As far as I understand it, yes you can reverse it, but I’ve only tested the way shown. Still, with backups what can go wrong….
Why would you prefer www, if you don’t mind me being nosey?
I don’t really have a preference.. just chose to go with www from the beginning as set it as my preferred domain with G Analytics.
I guess I’m just too lazy to go back into Analytics to change the settings (if that’s even needed)
I haven’t done much reading on the subject, though. Are there any benefits for having no-www?
I don’t think there are any benefits one way or another as long as you pick one & stick with it. According to the link non-www is just more ‘correct’.
Hey Chris:
I have a similar issue, but it’s a little different.
I have my Wordpress installation sitting in http://www.eJabs.com/blog . However, I want people to hit http://www.eJabs.com as the only front page.
The biggest problem is, Technorati see’s eJabs as two separate blogs, so my ranking is lower than it should be.
Can using a similar code in .htaccess help resolve my issue?
Thanks!
Also, please note:
I have two .htaccess files! One in the root & one in /blog.
The content of both files is exactly the same, except for one line that reads:
“RewriteRule . /index.php [L]” for the .htaccess root file. And:
“RewriteRule . /blog/index.php [L]” for the .htaccess root/blog file.
Can anybody help?
Thanks.
Hi Matthew,
Hope my email didn’t make things more confusing
I reversed your example and it worked fine. I put www in front when I started the blog and don’t want to change it.
Another note: Certain other websites like pageranker.org treat a subdomain (any subdomain) just like the root domain. This 301 redirect may actually stop that behavior as well. (I like having the pagerank plugin for Firefox instead of relying on an outside service.)
Is that the ‘gapr’ plugin (PR and Alexa) or is it a different one? Gapr slowed down the loading of my dashboard so much (or rather Alexa did) I disabled it.
Thanks for this info. Maki from DoshDosh.com directed me here and I am very greatful. I had a PR 0 with the www but a PR 4 with out. So now I have it all fixed. Thanks again!
No problem Mona, glad it helped
Hi Chris,
Thanks for this, and the comment on my blog. Unfortunately my website is running on IIS and therefore I don’t have a working .htaccess file. I’m using a custom 404 handler to deal with Wordpress permalinks, but this wouldn’t be called in this instance and I need something tha tintercepts the HTTP call, rather than a reactive solution. Thanks for the tip though.
Nice blog btw. Subscribed to your RSs feed
Thanks Owen, I won’t pretend to understand half of what you’ve said, but good luck with your PR anyway.
Thanks for subscribing, hope you find it useful
[...] a 301 HTTP Redirect to stop it from happening again. The elegant way to do this is to use an entry in your .htaccess file, however as I’m on IIS I didn’t have this luxury. Instead, I implemented this in the [...]
thanks i just used this tip again!
for some reason my redirect got broken so i didnt have it anymore
Leave A Reply