Use .htaccess to redirect your http://yoursite to http://www.yoursite

Often you get necessities to have your website URLs as, though you would have configured your website URL as

The difference seems to be very naive, but in reality this affects lots of factors. Some search engines identify them as two different sites. Javascript libraries like mootools throw access denied errors when they are different and so on…

You can force the search engines, users and website visitors to ultimately see the www prefixed pages, by doing the following change to the .htaccess file on your website.

1. Create/Edit .htaccess on your public_html folder

2. Add the following lines to .htaccess after the “RewriteEngine on” statement

RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*)$1 [R=301,L]

For example for, the entries would be:

RewriteCond %{HTTP_HOST} !^www\.google\.com
RewriteRule (.*)$1 [R=301,L]