I have a photography website up and have been on page 5 of Google for my key-phrase for some time now. A few weeks back I learned about the Canonical meta tag. It essentially tells the search engines, “hey search engine…my website is www.site.com not site.com.” It also helps to avoid the penalty by Google for having duplicate content by telling the search engine to permanently index your site as “www” or with no “www,” depending on what you specify. Some search engines view “www.site.com” and “site.com” as two different sites, therefore seeing it as duplicated content. We know that they are not separate sites, but search engines think they are.
Armed with this information I made ONE edit to my .htcaccess file (only works if you have your own hosting account), and it moved us up 5 pages on Google to page 2. The .htcaccess file is located in your root folder of your hosting account. *Please note – We are not responsible if you mess this up. Backup the file before you do anything at all.*
Below is the code to add to your .htcaccess file. You ONLY need to replace what’s in red.
This is the code you’ll use if you want WWW in front of your domain name.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
This is the code you’ll use if you DO NOT want WWW in front of your domain name.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
*EDIT*
We had a few folks as about the other way around so we edited the original post and posted both codes. If you happen to have a WordPress blog at the root of your hosting account you’ll need to add whichever line of code AFTER the WordPress code.