Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

share|improve this question
    
In other words... if the domain is not "subdomain3.domain.com" then redirect to this? –  w3d Jun 9 '11 at 14:32
    
yes, thats correct –  xLRDxREVENGEx Jun 9 '11 at 18:08
add comment

1 Answer 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]
share|improve this answer
    
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 –  xLRDxREVENGEx Jun 10 '11 at 7:25
    
Should work now. –  toscho Jun 10 '11 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. –  xLRDxREVENGEx Jun 10 '11 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? –  toscho Jun 10 '11 at 18:26
    
wheres my rewrite log going to be –  xLRDxREVENGEx Jun 10 '11 at 22:53
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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