420 Creative - Portland Web Design Studio

To show www or not to show www

Mar 09 2009

Angie Herrera

Web Development

Back in November I wrote about how having a parked domain can potentially be seen as duplicate content by Google. While not as common in terms of getting penalized for it (in fact, I've never heard of that happening), another thing to look at is whether or not your site is accessible with or without the www in front. (I'm referring to top level domains here and not subdomains of course.) Or worse, that your site only works with one of those two. ### Um, so? Let me give you an example. Take the [OASA website](http://www.oregonadultsoccer.com). Open a new browser tab or window and type in www.oregonadultsoccer.com Got it? Okay, now, place your cursor in the address bar and remove "www.". Still loads? Great. Sort of. See, there's potential here for search engines (Google in particular) to see those two URLs as different "versions" of your site. Matt Cutts [said it best in 2006](http://snipurl.com/azjc9): > ...most people would consider these the same urls: > > - www.example.com > - example.com/ > - www.example.com/index.html > - example.com/home.asp > > But technically all of these urls are different. A web server could return completely different content for all the urls above. When Google "canonicalizes" a url, we try to pick the url that seems like the best representative from that set. ### What's the right way? So which one is best? The answer is it doesn't matter so long as you pick one and stick with it. Our site, for instance, leaves out the www in front. Go ahead, try typing in our URL with the www in front. See what happened? It redirects to the non-www "version". And really that's all you have to do. ### How it's done If you're on an Apache server the fix is an easy one as long as you have access to your .htaccess file. If you want to ***remove*** the www, use this (swapping out example.com for whatever your domain is):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
If you want to ***keep*** the www, use this (again, swapping out example.com for whatever your domain is):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
And that's all folks.