As first asked on http://bit.ly/1hYKkHC and http://bit.ly/1hYKtL9 Apache 2.4.7 on Ubuntu 14.04. The rewrite rule is simple: RewriteCond %{REQUEST_URI} ^/?$ RewriteRule ^ /web/wp-content/cache/page_enhanced/HOSTNAME/_index.html [L] Basically, I want to serve an .html file for /. The .html file exists and is served fine if requested directly. As you can see in the debug logs below the cond on / does match (initial), but then Apache proceeds (subreq) and tries to match /index.html, /index.cgi, /index.pl and /index.php, and finally serves /index.php. This is not expected since [L] should prevent Apache from continuing once a match is found. I can confirm that this problem does not exist in Apache 2.2. Also, this appears to be a problem only for /. The same rule but for a subdirectory works as expected, i.e.: RewriteCond %{REQUEST_URI} ^/subdir/?$ RewriteRule ^ /web/wp-content/cache/page_enhanced/HOSTNAME/subdir/_index.html [L] ... works just fine. Rewrite debug logs: # grep rewrite: /var/log/apache2/error.log [Sat Apr 19 20:40:14.581933 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabc90a0/initial] [perdir /var/www/HOSTNAME/] strip per-dir prefix: /var/www/HOSTNAME/ -> [Sat Apr 19 20:40:14.581957 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabc90a0/initial] [perdir /var/www/HOSTNAME/] applying pattern '.*' to uri '' [Sat Apr 19 20:40:14.581963 2014] [rewrite:trace4] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabc90a0/initial] [perdir /var/www/HOSTNAME/] RewriteCond: input='/' pattern='^/?$' => matched [Sat Apr 19 20:40:14.581966 2014] [rewrite:trace2] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabc90a0/initial] [perdir /var/www/HOSTNAME/] rewrite '' -> '/web/wp-content/cache/page_enhanced/HOSTNAME/_index.html' [Sat Apr 19 20:40:14.581969 2014] [rewrite:trace1] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabc90a0/initial] [perdir /var/www/HOSTNAME/] internal redirect with /web/wp-content/cache/page_enhanced/HOSTNAME/_index.html [INTERNAL REDIRECT] [Sat Apr 19 20:40:14.582407 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] strip per-dir prefix: /var/www/HOSTNAME/index.html -> index.html [Sat Apr 19 20:40:14.582414 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] applying pattern '.*' to uri 'index.html' [Sat Apr 19 20:40:14.582418 2014] [rewrite:trace4] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] RewriteCond: input='/index.html' pattern='^/?$' => not-matched [Sat Apr 19 20:40:14.582420 2014] [rewrite:trace1] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] pass through /var/www/HOSTNAME/index.html [Sat Apr 19 20:40:14.582767 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] strip per-dir prefix: /var/www/HOSTNAME/index.cgi -> index.cgi [Sat Apr 19 20:40:14.582772 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] applying pattern '.*' to uri 'index.cgi' [Sat Apr 19 20:40:14.582775 2014] [rewrite:trace4] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] RewriteCond: input='/index.cgi' pattern='^/?$' => not-matched [Sat Apr 19 20:40:14.582777 2014] [rewrite:trace1] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] pass through /var/www/HOSTNAME/index.cgi [Sat Apr 19 20:40:14.583131 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] strip per-dir prefix: /var/www/HOSTNAME/index.pl -> index.pl [Sat Apr 19 20:40:14.583136 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] applying pattern '.*' to uri 'index.pl' [Sat Apr 19 20:40:14.583143 2014] [rewrite:trace4] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] RewriteCond: input='/index.pl' pattern='^/?$' => not-matched [Sat Apr 19 20:40:14.583146 2014] [rewrite:trace1] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] pass through /var/www/HOSTNAME/index.pl [Sat Apr 19 20:40:14.583375 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] strip per-dir prefix: /var/www/HOSTNAME/index.php -> index.php [Sat Apr 19 20:40:14.583380 2014] [rewrite:trace3] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] applying pattern '.*' to uri 'index.php' [Sat Apr 19 20:40:14.583383 2014] [rewrite:trace4] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] RewriteCond: input='/index.php' pattern='^/?$' => not-matched [Sat Apr 19 20:40:14.583386 2014] [rewrite:trace1] [pid 20459] mod_rewrite.c(468): [client 192.168.198.1:14715] 192.168.198.1 - - [HOSTNAME/sid#7fd7ed4f0528][rid#7fd7dabcd0a0/subreq] [perdir /var/www/HOSTNAME/] pass through /var/www/HOSTNAME/index.php
mod_dir is looking for DirectoryIndex'es. There is a fix to the interaction between the two mods in 2.4.9, can you confirm it fixes your problem? *) mod_dir: Don't search for a DirectoryIndex or DirectorySlash on a URL that was just rewritten by mod_rewrite. PR53929. [Eric Covener]
I just tried 2.4.9 and indeed the reported problem is gone. If any Ubuntu users read this, there is a fairly actively maintained PPA at https://launchpad.net/~ondrej/+archive/apache2 which works fine in Trusty, so no need to compile.
thanks for verifying *** This bug has been marked as a duplicate of bug 53929 ***