ModRewrite redirect dynamic sub-domains
I'm trying to achieve the following :
when user is trying to ac开发者_运维知识库cess "user1.domain.com"
I'd like to redirect to : "user1.anotherdomain.com"
I've tried this rule, but that didn't work
RewriteRule ^(.*).domain.com$ $1.anotherdomain.com [R=301,NC]
Any help is much appreciated!
Sounds like this ought to work:
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^/(.*)$ http://%1.anotherdomain.com/$1 [R=301]
精彩评论