RewriteCond %{HTTP_HOST} !^test\.domain2\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://test.domain2.com/$1 [L,R=301]