Redirecting your domain.com to www.domain.com
April 19th, 2010
With people taking steps to make their website search engine friendly, there are some basic things which can be done to get on the better side of Google. Redirecting non www domains to www domains avoids the issue of duplicate content being indexed on search engines.
Below is the code which you need to put in your .htaccess which will redirect any user who types in yourdomain.com to www.yourdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Please change example.com to your website url.






Comments
Hi,
Can this be done on wordpress Blog as well?
What is the benefit of doing it?
SiRU
Yes, this is automatically done by WP when your specify your URL in Settings. The benefit of doing this is that it eliminates the chances of duplicate content issue with search engines.
[...] Related Articles: 1. Redirecting your non www domain.com to http://www.domain.com using .htaccess [...]