You will need a second RewriteCond . You can apply as many as you want to the RewriteRule .
Assuming something that is not sub.mydomain.com should be www.mydomain.com , here is your code:
RewriteCond %{HTTP_HOST} !^sub.mydomain.com$ RewriteCond %{HTTP_HOST} !^www.mydomain.com$ RewriteRule ^(.*) http://www.mydomain.com/$1 [QSA,L,R=301]
But you can simplify this by using the pipe ( | ) symbol in Regex:
RewriteCond %{HTTP_HOST} !^(sub|www).mydomain.com$ RewriteRule ^(.*) http://www.mydomain.com/$1 [QSA,L,R=301]
Scott Stevens
source share