Forum Moderators: phranque
I'm in need of some quick guidance on the best way to redirect any traffic to a specific directory on a site to another page. I have a sub-directory on my server that needs to be redirected to another page, due to some needed changes.
Example:
/sub/index.php => /gone.php
/sub/view.php => /gone.php
/sub/print.php => /gone.php
/sub2/index.php => leave alone
Thanks in advance!
They don't all play well together
Can you explain this a little more?
I know that there are many possible server configurations and that as the .htaccess file grows things can get complicated, and you mentioned in another thread that execution order may depend on the load order of modules specified in the httpd.conf file.
But across several shared hosts (and my local installations) I have never had a problem with such conflicts - in all cases I have Redirect and RedirectMatch calls at (or near) the top of the file and everything involving mod_rewrite below them.
Am I just lucky, or should I get out more?
...
I have seen jdMorgan warn of this so many times now, that it is always on my mind on any job involving any sort of redirects and/or rewrites. Just because it appears to work OK now, doesn't mean that it won't keel over tomorrow when your host upgrades Apache by a point release and makes minor (to them) changes to the configuration. :-)
You might also be interested in [webmasterworld.com...] especially posts #3790261 and #3790916 too.
The second post by jdMorgan in this thread is useful [webmasterworld.com...] - post #3790425 that is.
I have noticed a few minor configuration discrepancies between the hosts I use, but over the years I have evolved .htaccess techniques that work on all of them by trial and error.
Plenty of trial, and plenty of error :)
...