I have this in my .htaccess file:
RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com$1 [R=301,L]
but whenever I
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
This will redirect your domain which is not started with WWW It is not redirect your all sub domain.
It is useful.