htaccess add www

20.Jul.2010

In order to force your domain using www, you can use following .htaccess snippet. This snippet makes htaccess add www to your domain name.

1
2
3
4
5
6
RewriteEngine on
 
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]