Page is a not externally linkable
Angonasec - 11:27 am on Aug 18, 2010 (gmt 0)
Thanks for the tweak Jim.
I take it this thread ONLY refers to ordering: Access, Redirects, and Rewrites.
Therefore other things like; caching, Expires, and DirectoryIndex, etc can be placed in any order and any position within an .htaccess file.
However, it's probably worth mentioning another source of confusion in htaccess ordering.
I recently ran into an htaccess order related snag with the way my virtual host makes subdomains and merges the htaccess files.
My host makes subdomains like Folders within the main directory and then "invisibly" de-merges them via the server configuration merging:
So the actual directory arrangement is this:
www/.htaccess/subdomain/.htaccess
And the server ("invisibly") makes the site urls appear to be like this:
www/.htaccess
subdomain/.htaccess
As an aside:
In case the "invisibility" breaks-down, and the wrong url shows, I do have as insurance the redirect:
redirect 301 /subdomain/ htttp://subdomain.example.com/
(NB: Extra "t" added to foil WebmasterWorld bug)
A further complication is that my host has disabled htaccess inheritance in order to facilitate their custom access logging package. Therefore most of the www htaccess data has to be repeated in the subdomain htaccess file. (Very inefficient, but apparently my fellow virtual hosters can't live without tagged access logging!)
The problem I'm highlighting arose when I used <Files *>. ..</Files> and <Limit> ...</Limit> containers in various places in my www and subdomain files. Most of my access directives stopped working, and I finally had to abandon using "containers" like this and used Rewrites in their place.
There were none of the usual 500 server errors, it was far more obscure. The CTO advised that I'd run into a very complex "container precedence problem". They had stopped inheritance, but not precedence! None of the CTO's suggested fixes worked, and he concluded:
"When you start having multi-level .htaccess files like yours, the complexity of it all increases exponentially due to scope and how the various directives interact with each other..."
Apparently during the +server level merging+ of the various htaccess instructions, some are obeyed, and some are ignored, depending on their placement.
I tried many variations of my <Files *> and <Limit> containers, but couldn't get them to work as desired, so put the contained instructions into Rewrites instead, then things worked properly.
I only mention this here to show how a subtle change of order between htaccess files, as well as within htaccess files, can seriously roger things. aka "container precedence problem".