views:

17

answers:

1

Are these url rewrite rules and conditions correct?

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

Basically, URL needs to be rewritten from non-www to www.

Thanks

+2  A: 

I would probably use a more generic rule:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

But this rule does the same.

Gumbo