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 know this may seem a bit of a question in reverse, but I actually don't seem to have a problem I just want to make sure before I proceed.

I have 2 domains domain1.com and domain2.com and a directory my_directory at domain2.com.

I have domain2.com setup as an "add on domain" in the cpanel account of domain1.com so that when I go to domain2.com I am taken to domain1.com/my_directory but the browser shows domain2.com in the addressbar so it looks and acts like and is a separate site.

However when people browse to domain1.com/directory I want the address bar to show domain2.com not domain1.com/directory. So I put a redirect in the htaccess file to redirect domain1.com/directory to domain2.com and it works perfectly, but I think it shouldnt and I'm worried I've done something wrong.

My question is this: domain2.com was already redirected to domain1.com/directory in the first place (I see the redirect in my cpanel under addon domains) so by adding the second redirect in the htaccess file I should be creating a loop!

Could somebody please set my mind at rest and show me why not?

share|improve this question
    
nice edit jeff you make it seem so easy !! –  byronyasgur Jun 30 '11 at 0:06
add comment

migrated from stackoverflow.com Jun 25 '11 at 10:21

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

You are using 2 different mechanisms.

You have a redirect so that when someone visits domain1.com/my_directory they are redirected to domain2.com.

You have a rewrite so that when someone visits domain2.com they actually see the content from domain1.com/my_directory. This is processed internally within apache. It is not processing the redirect rule.

share|improve this answer
    
thanks - that would make sense but cpanel calls it (under addon domain) a redirect not a rewrite could this be a bit erroneous that would explain it –  byronyasgur Jun 24 '11 at 14:59
add comment

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.