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