简体   繁体   English

RewriteRule ^ - [L] AKA RewriteRule插入符号L

[英]RewriteRule ^ - [L] AKA RewriteRule caret dash L

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. 虽然我可以打开Rewrite Logging并弄乱这个规则来弄清楚它做了什么(如果有的话),我打赌有人已经知道了。 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. 所以我看到外面的机会,这意味着别的东西。

  • ^ is a somewhat unorthodox way of saying "match anything", just as you say 就像你说的那样, ^是一种有点非正统的说法“匹配任何东西”
  • - means "take no action" -意思是“不采取行动”
  • [L] means "last rule" ie stop processing RewriteRules after this point [L]表示“最后一条规则”,即在此之后停止处理RewriteRules

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 . 我假设在此之后还有其他规则,因为RewriteCond / RewriteRule这种组合表示如果当前请求是针对现有文件或目录,则mod_rewrite忽略任何后续的RewriteRules


Expressed in code, this would be equivalent to: 用代码表示,这相当于:

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

  // other rules
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM