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.
by Nick
7 comments
add a comment
link to this post
e-mail a friend
Gareth Robins - September 23, 2009 - 2:18 am
Will the new SEO update take care of this for those of us that choose to have Showit our sites?
admin - September 23, 2009 - 12:00 pm
Hi Gareth! This update *should* be a builder update so these new features should be included whether you are hosting with Showit or hosting yourself.
joe - September 10, 2009 - 11:52 am
is the way its written now going to make the search engine think its hey my site is http://www.xxxx.com or xxxx.com?
i am partial to NOT having the www
thanks for the help!
admin - September 10, 2009 - 11:58 am
Hi!
No the code above is to redirect from no www to a www. As soon as I get back to the office ill update this post with both codes. Ill email you when we do that. Thanks for stopping by!
admin - September 10, 2009 - 5:57 pm
Hey There,
This is the code you’ll need to redirect WWW to NO WWW.
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Brody - September 8, 2009 - 10:26 am
Hey,
Thanks for the tip, but when I put the code in it gave a redirect error and wouldn’t open the site. Saying that there were too many redirects trying to access the site at the same time.
Brody
admin - September 8, 2009 - 10:42 am
Hi Brody! Your .htcacces file sounds like it’s corrupted. Make a new file by using a plain-text editor. The output should be set to US-ASCII format. I also hope that you backed up your original .htcaccess file.