Redirect from non-www to www

We’re often asked how to achieve this, whether it be to prevent duplicate content or force a site to use your SSL.

This is really easy to do, open up the .htaccess in the public_html folder of your site and add:

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

This will redirect any requests that don’t match the www version of your site to the www version. It will use a 301 Permanent redirect.

Leave a Reply

Your email address will not be published. Required fields are marked *