问题
I want to redirect every subdomains of domain1.com to domain2.com
foo.domain1.com -> foo.domain2.com
baz.domain1.com -> baz.domain2.com
bar.domain1.com -> bar.domain2.com
etc
回答1:
https://stackoverflow.com/a/8046069/2024688
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain1\.com$ [NC]
RewriteRule ^(.*)$ http://%1%2.domain2.com/$1 [L,R]
来源:https://stackoverflow.com/questions/17141021/htaccess-redirect-any-subdomain-domain1-com-to-domain2-com