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