How do folks? I have three Websites hosted by my ISP each each stored in it's own subdirectory off the root. I recently had to add an htaccess file to this root directory to redirect users from an old website address to a new domain I had purchased (again hosted in a sub-directory). However this htaccess file is now applying site-wide and across all aliases meaning all three of my sites now point to just one site As I understand htaccess files cascade downwards, so that if I have a .htaccess file in my root directory, /, and another in a sub-directory called /Wright, then when a file is requested from the /Wright directory Apache will merge the two files and use all the directives. Is there any way I can stop this behaviour - I have a 301 redirect in my root directory and I don’t want it to apply to the /Wright sub-directory. I have tried unsuccessfully putting a 301 redirect in the /Wright sub-directory to override the root but this has not been successful. Thanks in hopeful anticipation folks
Put another htaccess in the deeper folder. It overrides the root one provides you get the order correct in which the directives are executed. I had a similar problem and couldn;t crack it until I changed order alllow, disallow.
Thanks for the reply TOPS30 Can I please ask (in basic terms) how do I get the order correct in which the directives are executed? I'm also unsure about your allow/disallow statement if you could clarify please? I ask because I tried another .htaccess file in one of the sub-directories, but all that happened when I tried visiting the affected url was the browser hung. It kept trying to open the page but eventually timed out.
You could also replace your Redirect directives with RewriteRules (if you're able to use mod_rewrite on your server). That would allow you to use RewriteConds to determine whether to apply the rules to incoming requests, based on e.g. the URL of the request. In this scenario, you would need only one .htaccess, in the root directory. Check the mod_rewrite manual or search this forum for examples...