RewriteRule recurses in spite of [L]

Giganews Newsgroups
Subject: RewriteRule recurses in spite of [L]
Posted by:  Kaz Kylheku (k…
Date: Sat, 17 Sep 2011

A long time ago, in my <Directory /> node, I created this rewrite
condition and rule:

  RewriteCond %{REQUEST_URI} !^/var/www/
  RewriteRule ^(.*) /var/www/$1 [L]

If I remove the RewriteCond, in spite of the [L], there is an
infinite rewrite loop, leading to a server error for all pages
which rely on this rule.

I just temporarily reproduced this, obtaining the rewrite log entries
such as this one, for the favicon.ico: - - [17/Sep/2011:11:00:41 --0700]
[][rid#d3bba8/initial/redir#10] (1) [perdir /]
internal redirect with

I don't understand why Apache is repeatedly adding the /var/www prefix,
when the rule has a clear [L] in it.

Doesn't [L] mean: apply the rule, and then stop processing rewrite
rules, (including that rule itself)?