Below snippet shows how to redirect a site from non-www to www
1 2 |
RewriteCond %{HTTP_HOST} ^onlinenote.in$ [NC] RewriteRule (.*) http://www.onlinenote.in/$1 [R=301,L] |
or
1 2 3 |
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] |
or
Here’s the correct solution which supports https and http:
1 2 3 4 |
RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTPS}s on(s)|offs() RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R] |