RewriteCond %{SERVER_NAME} ^([^.]+\.[^.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
I want to rewrite mysite.com to www.mysite.com when no subdomain is indicated. If for example someone requests test.mysite.com then it will remain test.mysite.com, but mysite.com alone will be redirected to www.mysite.com.
Just wanted to make sure that what I have now is right and there are no possible problems in the condition and rule that I'm using. Solution above was recommended by one of the fellow SO users, but I replaced {HTTP_HOST} with {SERVER_NAME}