0

I need to redirect any domain to a sub-domain. I know this has got to be possible but for the life of me i can not figure it out. Any help is appreciated.

For example:

domain1.com
domain2.com subdomain1.domain1.com subdomain2.domain2.com

all go to subdomain3.domain.com

but i need code that does not require me to enter each domain i want redirected. So for any feature domains that i link or create will go to subdomain3.domain.com btw this will only happen when viewing anydomain.com/path <-- the path is a sym link

2
  • In other words... if the domain is not "subdomain3.domain.com" then redirect to this?
    – MrWhite
    Jun 9, 2011 at 14:32
  • yes, thats correct Jun 9, 2011 at 18:08

1 Answer 1

1

I’m not sure if I understand your question right. If you want to redirect all requests to path to subdomain3.example.com just compare the hosts:

RewriteCond %{HTTP_HOST} !^subdomain3\.example\.com$
RewriteRule ^path http://subdomain3.example.com/ [L,R=301]

Update

RewriteCond %{HTTP_HOST} !^subdomain3\.example\.com$
# At least one character after /
RewriteRule (.+) http://subdomain3.example.com/$1 [L,R=301]
7
  • ok so you really did not get it. I think. I just need any feature dome pointing to /path be redirected to the proper domain. so any domain coming into my site and pointing to /path will be redirected to subdomain3.mydomain.com/path Jun 10, 2011 at 7:25
  • Should work now.
    – fuxia
    Jun 10, 2011 at 10:10
  • can you explain a little more on this. It does not work somewhat. It seems like it trys to work but does not fully redirect. the domain address still shows domain1.com/path domain2.com/path but the style sheet goes away i need a complete rewrite of any domain. Jun 10, 2011 at 17:56
  • Then you have either later rewrite rules or your adaption is missing a critical part (maybe R=301?). What says your rewrite log?
    – fuxia
    Jun 10, 2011 at 18:26
  • wheres my rewrite log going to be Jun 10, 2011 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.