.htaccess redirect any subdomain *.domain1.com to *.domain2.com

╄→гoц情女王★ 提交于 2019-12-12 01:08:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!