Forum Moderators: phranque
I manage domain1.org and wish to pass on links to domain2.org and domain3.org appropriately.
A subset of my .htaccess has the following lines:
RedirectPermanent /health/environment.htm [domain2.org...]
RedirectPermanent /health/healthed.htm [domain2.org...]
RedirectPermanent /health/ [domain2.org...]RedirectPermanent /emermgmt/emergencyplan.htm [domain3.org...]
RedirectPermanent /emermgmt/ [domain3.org...]
So when I make the call:
[domain1.org...]
my browser instead fetches:
[domain2.org...]
This principle works for the case of /health/ above, however, the same principle does not work for /emermgmt/. Instead of getting [domain3.org...] I get a 404 as [domain1.org...]
What might I be doing wrong?
Jim
..and you've hit it! My first implementation of redirects, which hit only /health by creating a physical subdirectory (/health) with a php redirect, was confusing me. My /health/index.php contained:
header("HTTP/1.0 301 Moved Permanently");
header("Location: http://www.domain2.org/");
The proper solution to handle both cases (/health and /health/) in my .htaccess is to graduate from RedirectPermanent in favor of RedirectMatch which supports regular expression. The following seems to work:
RedirectMatch 301 /health/?$ http://www.domain2.org/
RedirectMatch 301 /emermgmt/?$ http://www.domain3.org/
thanks!
-bronius