Did you know the URLs “www.The SEO Blogger.com” and “http://The SEO Blogger.com” are distinct URLs and are treated differently by the search engines?
This has to do with URL canonicalization. What’s URL canonicalization you ask?
According to the head of Google’s Webspam team, Matt Cutts, URL canonicalization is “the process of picking the best url when there are several choices”:
* www.The SEO Blogger.com (same as www.The SEO Blogger.com)
* The SEO Blogger.com (same as http://The SEO Blogger.com)
* www.The SEO Blogger.com/index.php
* The SEO Blogger.com/home.asp
Most people think that those are the same, but on technical term, they are NOT!
*Can you see how the URLs are different, even though they may serve up the same web page?
Luckily, after a major update to “Big Daddy,” Google now is able to detect which one is the best URL for you/your website. However, you do have to help Big Daddy in the process.
How do you help make sure Google pick the URL that you want?
Well, for your internal linking, the URL that you use should be ‘consistent’. For example, if I’m planning to use “http://The SEO Blogger.com” as the consistent URL form for all of my EXTERNAL inbound links, it’s wise to use that URL form in ALL my internal linkings, as well. And, as you can see, I have done just that.
*Note: the reason you don’t want to have half of your links pointing to “http://yourdomain.com” and the other half to “http://www.yourdomain.com” is because you do NOT want to split the value of those links up. You want to have one ‘consistent’ URL form, so that your website (page rank) will receive the FULL benefits of ALL the links, not just HALF of them.
–But here’s the problem, you only have control over the URL form of those external/internal links if you are the one who’s placing those links (URL form). For many other people who link to your website, you cannot control which URL forms (http://www. or http://) they will link to you.
Thus, in order to receive FULL benefit of consistent URL, you need to set up a 301 permanent redirect from one URL form to another, which is pretty easy–as shown below:
Using Mod Rewrite to Redirect “Non-www” URL (http://) to “www” URL (http://www.)
In order to do this, you must have access to the .htaccess file via FTP or CPanel File Manager. Most Apache web server (Linux hosting) has this .htaccess file. If not, you can create and name the new file .htaccess and place it inside the root directory of your domain (e.g. public_html/.htaccess).
You must edit/add the following mod-rewrite script to your .htaccess file to redirect “http://” to “http://www.”:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ www.%1.%2%{REQUEST_URI} [R=301,L]
The above script will redirect:
http://yourdomain.com to http://www.yourdomain.com
Redirecting “www” URL (http://www.) to “Non-www” URL (http://)
This is the simple mod rewrite script I use to redirect “http://www.The SEO Blogger.com” to “http://The SEO Blogger.com“:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.TheSEOBlogger.com [nc]
RewriteRule (.*) TheSEOBlogger.com/$1 [R=301,L]
*Note: you should change “The SEO Blogger.com” to YOUR WEBSITE NAME! Also, if you have sub-domains, the above script will also work. Also, by ‘default’, I think WordPress gives your site URL as “http://www.yoursite.com.” If you want your site to be in “http://” URL form, you, of course, have to go to “OPTION ->General” and update your site URL to “http://yoursite.com” instead of “http://www.yoursite.com.”
Anyway, here is a live demo of those two scripts at work:
http://mint-tree.com >>> www.mint-tree.com
http://www.TheSEOBlogger.com >>> TheSEOBlogger.com
By using either one of these mod-rewrite scripts, you can have a consistent URL in your linking campaign. Now, you don’t have to worry what URL form others have used to link to your website. Now “http://” and “http://www.” are ‘consistently’ the same, although I think “http://” is a better URL form for your SEO linking campaign, just because that form is SHORTER than “http://www.”
.
If you like "Using Mod-rewrite to Redirect Non-www URL to www URL,"
please consider linking to this page:


[...] Using Mod-rewrite to Redirect Non-www URL to www URL [...]
I like the script you have provided. However, it doesn’t work on the my domain with .us
eg, ABC.us
Please help, it shows the following:
Redirect Loop
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.
* Have you disabled or blocked cookies required by this site?
Reply to this comment »* NOTE: If accepting the site’s cookies does not resolve the problem, it is likely a server configuration issue and not your computer.
Thank for your tips, i has been looking this rewrite from non-www to www quite sometimes, i definitely will bookmark your URL
Reply to this comment »There is an error in the code …
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]
should be
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]
that is why it is looping
Reply to this comment »is there a way to simply rewrite any www domain to non-www domain without having to list the domain name each time?
Reply to this comment »Hi,
I have follwed the above steps to Redirecting non www URL to www URL through mod_rewrite but its giving HTTP/1.1 200 OK in Server Header Checker Tool it is not redirecting….
Any solutions..
Reply to this comment »