Apache subdomain and domain redirections
I have the following situation to tackle, i have a domain and a subdomain pointing to the same resource.
www.mydomain.com and sub1.mydomain.com
What i'm trying to achieve is the following:
i would like the subdomain to
redirect its root to a sub-folder of the system. So sub1.mydomain.com --> sub1.mydomain.com/subdomainsrootfolder/sub1/
redirect back to the main domain when a uri not below the "/subdomainsrootfolder/sub1/" structure is requested. i.e. sub1.mydomain.com/subsrootfolder/sub1/(开发者_如何学C) to be served normally but if sub1.mydomain.com/() is requested to redirect to www.mydomain.com/(*)
thanks a lot for any insights!
ex.
case 1. sub1.domain.com --> sub1.domain.com/subrootfolder/sub1/
case 2. sub1.domain.com/subrootfolder/sub1/* --> as is
case 3. sub1.domain.com/anyotherfolder/ --> www.domain.com/anyotherfolder/
case 4. www.domain.com/subrootfolder/sub1/* --> sub1.domain.com/subrootfolder/sub1/*
maybe these examples are more explanatory than the text above... :)
RewriteCond %{HTTP_HOST} www\.mydomain\.com
RewriteRule ^/subrootfolder/sub1/(.*) sub1.domain.com/subrootfolder/sub1/$1 [redirect,last]
RewriteCond %{HTTP_HOST} www\.mydomain\.com
RewriteRule / - [last]
RewriteRule ^/$ sub1.mydomain.com/subdomainsrootfolder/sub1/ [redirect,last]
RewriteRule ^/subdomainsrootfolder/sub1/ - [last]
RewriteRule ^/(.*) www.mydomain.com/$1 [redirect,last]
精彩评论