WebsiteKnowledge Base

How to redirect non-www to www

To enable a permanent redirect from the non-www version of the site to the www version the following code will need to be placed into a file named .htaccess that is located in the www directory for the site this is to be enabled for.

If the .htaccess file does not exist or does not have the following line it will need to be added first:
RewriteEngine On
To enable the non-www to www redirect add the following lines to the .htaccess file, after the above line, and replacing example.com with the domain name of the site.
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]