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