Web Development

December 1, 2009

Redirecting non www to www for SEO and Certificates

Filed under: SEO, Technical, Webserver — Rob @ 4:58 pm

You might have noticed, in most cases the “www” is not a necessary part of a url anymore.  It used to be, but that all changed some time ago. This created a bit of a problem for website admins when it comes to SEO.

Take this scenario – Bob has a site called “cans.com”   and you can view it both at http://cans.com     and at    http://www.cans.com

Google goes out to index the site and ends up indexing it basically as two pages, some links are here – some are there.

For SEO purposes you could see why this is less than ideal – your site will suffer in page rank and placement as it is essentially being looked at as two separate sites.

Take this scenario as well, Bob’s site “cans.com” sells cans (I know, crazy huh?) and Bob went out and got himself an SSL certificate to make that secure. He went and bought a cert for  http://www.cans.com

Still with me? Good.  Now a potential customer goes to Google to search for cans – ends up finding http://cans.com – clicks the link to the site – and tries to make a purchase.

Except the link he followed is http://cans.com and the SSL certificate was issued to http://www.cans.com……   so the user gets a HUGE security warning that the certificate was not issued to this site and leaves.


(would YOU continue?)

Multiply that by all  the potential customers that come by in a typical month and you’re losing some serious business.

So, follow the instructions below for either IIS or Apache and in 30 seconds problem avoided.


Create your website (http://www.cans.com) – verify it works, upload content, install cert if you need one.

Create another website from scratch – set it’s host header to cans.com

  1. In the Home Directory tab, change the option button “When connecting to this resource the content should come from” to “A redirection to a URL”.
  2. Specify the URL as http://www.cans.com
  3. Check the checkbox that says “A permanent redirection for this resource.”



For those of you using Apache the steps are somewhat easier, you need to edit your root htaccess file (or create one if you don’t have one) and your server needs to have mod_rewrite installed (most do)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

** Authors note, there’s no reason you HAVE to go with the “www” as your main site – redirecting to a non www address is perfectly acceptable – I just picked the www as the standard as that’s what most of the big guys are doing still.