[Bug 711465] [NEW] mod_rewrite directives in <Location> section confusingly disable rewrites in .htaccess

Daniel Richard G. skunk at iskunk.org
Tue Feb 1 20:14:11 UTC 2011


Public bug reported:

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/httpd.conf ...

    <Location />
        RewriteEngine On
    </Location>

...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.

** Affects: apache2 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to apache2 in ubuntu.
https://bugs.launchpad.net/bugs/711465

Title:
  mod_rewrite directives in <Location> section confusingly disable
  rewrites in .htaccess



More information about the Ubuntu-server-bugs mailing list