Re: Re: RewriteRule in neither "foo/.htaccess" nor ".htaccess" can match http://example.com/.../foo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jack Bates wrote:
...
Hi again.
I am not saying here that you are necessarily wrong, or that there is
not a good justification to what you are trying to do, or to what you
asserted at the end of the previous post.

But one thing you should be aware of, is that when you place
instructions in a .htaccess file, you are in fact asking Apache
to walk down the whole directory tree, applying all its configuration
rules level by level as it does so, until it gets to the level of the directory where it finds the first .htaccess file.
Then, because this .htaccess rewrites the URL, you are basically telling
Apache to throw away all the result of its previous work, and to start
again at the top with the new URL.  Then, in your case and assuming
everything works down to that level, it will end up at the level of the
subdirectory, and find again a .htaccess with rewrite rules. So it will
again rewrite the URL, and again restart at the top.
In the best of cases, that is rather inefficient.
In the less best case, you have missed an intermediate transformation
somewhere, which is leading to a series of rules being applied, that is
different from what you expect.

My personal point of view is that one should avoid .htaccess files if one can, which is most of the time when one has access and can modify the main server configuration files, as you seem to be able to. .htaccess should be reserved for cases where one does not have access to the server condiguration, and only to one's own directory for instance.

I have not followed your rules step by step, and do not really wish to, and do not have access to your full configuration sequence of directives anyway. But given that Apache is being used on hundreds of thousands of sites, many of them using mod_rewrite and .htaccess files, and apparently seems to be doing fine most of the time, my current odds would be in the order of magnitude Apache 10 / Jack 1.

It may be so for instance that what is interpreted the first way around as the request filename, is no longer considered as such if there is a subdirectory below the current one. Or some other such apparently obscure side-effect.

So anyway, if it does not work the way you want when you have a hierarchical set of rewrite rules in .htaccess files, it may be worth asking yourself if it is not possible to remove one such level and move the corresponding rules into the main part of the configuration, which would probably be more efficient anyway.




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux