Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Force www vs non-www to avoid duplicate content on Google

Be First!
by April 7, 2011 HTACCESS

Force www vs non-www to avoid duplicate content on Google

Now a Days, it has been talked a lot about Google and duplicate content as well as Google Canonical problems.That is, when you have your site accessible both under your_domain.com and www.themoderneducation.com. To avoid such problems you can use the following lines in your .htaccess file to force only the www version of your web site:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.themoderneducation.com$
RewriteRule ^(.*)$ http://www.themoderneducation.com/$1 [R=301]

Please, note that the .htaccess should be located in the web site main folder.

This will redirect all requests to the non-www version of your site to the www version using 301 Permanent redirect which will make the search engines to index your site only using the www.themoderneducation.com URL. In this way you will avoid a duplicate content penalty.

(426)

Previous
Next

Leave a Reply