mod_rewrite directives in <Location> section confusingly disable rewrites in .htaccess
Binary package hint: apache2.2-bin
Reporting this against version 2.2.16-1ubuntu3.1 in Maverick.
I have apache2 configured in the following way:
1. mod_rewrite is enabled;
2. "AllowOverride All" is set (on /var/www) to enable the use of .htaccess files;
3. "RewriteEngine On" plus some basic rewrite rules are placed in /var/www/.htaccess .
This works. URLs are rewritten without issue. But then, if I add the following to the server config, say in /etc/apache2/
...then the rewrites stop working. There is no indication of why, no error or warning message given even with logging/debugging turned up to maximum---just .htaccess rewrite rules that refuse to work despite everything else seemingly in order. You get the same result if you have a RewriteRule directive in the <Location> section; it appears that any reference to a mod_rewrite directive therein leads to this situation.
This led to a lot of frustration on my part, because before I figured out that I had to change AllowOverride to get .htaccess files working, I tried adding mod_rewrite directives in a <Location> setting, and left them in, figuring they would be harmless at most.
After figuring out what was going on, I noticed that the mod_rewrite documentation states the following: "Although rewrite rules are syntactically permitted in <Location> and <Files> sections, this should never be necessary and is unsupported."
I think it would be helpful if mod_rewrite were to give a prominent warning or error if it is invoked in a <Location> (or <Files>) section, rather than behaving in the above-described confusing and undocumented manner.