.htaccess将任何子域* .domain1.com重定向到* .domain2.com

时间:2013-06-17 05:41:17

标签: .htaccess mod-rewrite redirect subdomain

我想将domain1.com的每个子域重定向到domain2.com

foo.domain1.com -> foo.domain2.com

baz.domain1.com -> baz.domain2.com

bar.domain1.com -> bar.domain2.com

etc

1 个答案:

答案 0 :(得分:0)

https://stackoverflow.com/a/8046069/2024688

RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain1\.com$ [NC]
RewriteRule ^(.*)$ http://%1%2.domain2.com/$1  [L,R]