#Force www: RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
OR
Even better, for all names:
[code:1:b9951d1bb3]RewriteEngine On
RewriteBase /
# non empty HTTP_HOST in the request
RewriteCond %{HTTP_HOST} !^$ [NC]
# does not start with ‘www’
RewriteCond %{HTTP_HOST} !^www. [NC]
# saves the value of HTTP_HOST in %1
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
# redirects using the saved URI (in RewriteRule) and saved hostname (in the last RewriteCond)
RewriteRule ^(.*)$ “http://www.%1/$1” [L,R=301]
# that’s it ![/code:1:b9951d1bb3]
source:
[url]http://drupal.org/node/93603[/url]
Leave a Reply