Htaccess redirect for non - www or both http and https
by Dinesh[ Edit ] 2014-09-16 13:15:39
You can easily redirect domain from www, non www, http to https by modifying your Htaccess file. You can do this feature by modify your Htaccess file with following simple code,
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
-> The first condition tests if the HTTP header field Host has the required format
-> The second condition tests if the value of the HTTPS variable is on or off and s is equal to ons and captures the s. This means if %{HTTPS}s evaluates to ons, the first matching group is s and empty otherwise.