.htaccess rewrite rule to keep subdomains when redirecting to new domain
.htaccess, mod-rewrite
Solution
You just need to add a `%1`
RewriteCond %{HTTP_HOST} ^(.*)oldomain.org [NC]
RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]
Problem
I am moving a site from an old domain with several subdomains to a new domain. I'd like to create a rewrite rule that will just swap out the old domain for the new one, but I am not savvy enough with regular expressions & .htaccess to do this :P I can get the 301 redirect working for the pages on the domain: ``` RewriteCond %{HTTP_HOST} ^(.*)oldomain.org [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L] ``` Any clues on how to modify this to include the subdomain as well? Or am I stuck listing all the subdomains in separate rewrites?