19

While I could turn on Rewrite Logging and mess with this rule to figure out what it does (if anything), I bet someone already knows. Here's the rule by itself:

RewriteRule ^ - [L]

Here it is in context:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

I guess it means "Match Everything". I'd have thought that "Match Everything" would be a dot to make it more obvious that there is no missing code, and that regexp would error out if the caret was the only thing in it. So I see the outside chance that it means something else.

Dave Scotese
  • 498
  • 5
  • 17

1 Answers1

24
  • ^ is a somewhat unorthodox way of saying "match anything", just as you say
  • - means "take no action"
  • [L] means "last rule" i.e. stop processing RewriteRules after this point

I assume there are other rules following this one, because this combination of RewriteCond/RewriteRule says that if the current request is for an existing file or directory, mod_rewrite should ignore any subsequent RewriteRules.


Expressed in code, this would be equivalent to:

do_rewrites(req)
{
  if (is_file(req) || is_dir(req))
    return;

  // other rules
  ...
}
Martin
  • 37,119
  • 15
  • 73
  • 82