Why you have to do the non-www to www redirect?
Some of the users follow the conventional method of typing the URL from www. if your website does not support this then there might be chances that your website is not loaded. Why to take chances.

How to redirect your website from non-www to www?
This is very simple add this code in .htacess, then you are set for the non-www to www.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

There are plenty of code available to do this job. But always use this method so that you do not want to worry about your domain name, if it is .com, .in, .net, .org this code will take care of it.

I will also write another post to use the reverse process.

Share This