Latest News

WWW vs. non-WWW URL Canonicalization Cookies

Canonical URLs. My first blog is going to be about something I encounter often when doing installs and working with other webmasters. The topic is the URL structure of a website and URL canonicalization, (new word).

URL Canonicalization: The process of choosing the BEST URL structure when there is a choice and then sticking to it.

For many of us, and look the same and more than likely will take you to the same website. Generally speaking, most of us don't give much thought at all to our URL structure or the difference between using www and not using www. However, the difference in your URL structure is VERY important! It's not only important for your client login cookie domain but it's also critical to Search Engine Optimization and uniformity across your website.

Why should I choose a URL structure?

First and most importantly you should choose a canonical URL structure for the purpose of SEO. Because WWW. is essentially a subdomain and search engines that will pick this up, (for example): and as two different domain names, likewise splitting the page rank between the two. This is considered page rank leakage and not something we want. If you have backlinks going to both the www. and non-www version of your URL, one will benefit and the other will not.

Secondly, some search engines that pick up both URLs and backlinks coming into www and non-www versions of your URL with the same content, will consider this duplicate content and search engines don't like duplicate content. Your site could be penalized because of this.

Third, you want to choose a canonical URL structure for the benefit of your customers when it comes to navigating your site. If you use two different domain names and they are logged into one, they may visit the other and they will not be logged in. To them, it's the same site but according to their browser cookies, they are not the same site. This could cause confusion and added support tickets from your clients because most of them won't notice a difference at all.

Which canonical URL structure should I use?

WWW vs. Non-WWW is a good argument and can go both ways. If you ask me personally, I always choose the non-WWW version of the url for several reasons:

  1. Shorter Domain - I prefer shorter domain names so the search engines can get to the keywords after the domain name that tell them what the page is about. If the domain name is too long and full of session ID's etc, then it may not be picked up quite as easily. There is no benefit at all having the www. in front of my domain name.
  2. Pure Domain Name - Using only the domain without the subdomain WWW is making use of the domain name in it's purity. Being a domainer myself, I'm a purist when it comes to the use of domain names and don't like the www. prefix.
  3. WWW Antiquated IMHO - When the web was in it's infancy it was considered the World Wide Web, hence the WWW. Today it's the Internet and in the past you'd see advertised on TV, today you rarely hear anyone say, 'visit my site at www...'. Now they just advertise the domain name.
The use of www vs. non-www URL structure is a matter of personal choice. However if your website has been online a while and has backlinks and internal links, and they were www. to begin with, then I'd recommend staying with the www. prefix and making that my canonical URL structure. However, if you are building a new site and don't have a lot of backlinks or page rank, then I'd suggest using the non-www version for all your URLs and linking.

I see this all to often when doing installs of the JWHMCS integrator, where the client has not chosen a canonical URL structure and I consider it a MUST for every webmaster to do with EVERY site they build. It has become an important step in my web development practices and it should be in yours as well.

Choose a URL structure and then stick with it!

How to I force it to one or the other?
On a Linux server which is what I'm familiar with, (can't stand windows) you can use a 301 permanent redirect in your .htaccess file. This is the correct method that will allow search engines to combine the value of any incoming links to your site. Our .htaccess 301 redirect from www to the non-www version looks like this:



Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
WWW to non-WWW could also be done like this:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^.*${REQUEST_URI} [R=301,L]
New Code by Hostgator Server Admins:


RewriteEngine On
 RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com$ [NC]
 RewriteRule ^(.*)$$1 [R=301,L]
Backup your .htaccess file in your website directory and use the one that works best for you and test it before going to live to make sure it works.

To redirect from non-WW to the WWW version of your site you could use something like this:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]
That's all folks. Pick a canonical URL structure, use it, make it permanent and apply to to each and every website you build and you'll only gain from it in the long run.
You are here: Home Latest News Blog WWW vs. non-WWW URL Canonicalization Cookies
More than 2000 members use our products and services on their website!   Register Now!
Premium SSL Certificate