Many customers at some point request to force either the www or non-www version of their site to display in their visitor’s browser. For example, you can have www.example.com or simply example.com display in an address bar.
Force www with htaccess
To force www with htaccess, look for the .htaccess via FTP and copy/paste this code. Be sure to replace ‘example.com‘ with your actual domain name.
#Force www: RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Force non-www with htaccess
Look for the .htaccess via FTP and copy/paste this code. Be sure to replace ‘example.com‘ with your actual domain name.
#Force non-www: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Now, when you type in your domain name with either www in front or not, it should display as you have set it in the .htaccess file.