No-www to www redirection

Add the following snipper to your .htaccess file in order to have your domain redirect to www. even if typed without that part. Just make sure where it says “” to fill in your actual domain on both lines 2 and 3.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$$1 [R=301]

Why would you want to do this? It makes your site nice and clean and loading off www.<your domain>.com

In addition this avoids the duplicate content penalty from search engines, because otherwise your site appears to have a site at “www.<your domain>.com” and at “<your domain>.com”.

Was this article helpful?
Spread the word!