Why don't I have a loop error with these redirects?
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about web-development, htaccess, redirects, webserver, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :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?
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.
Comments
Post a Comment