You will almost always want to use
[R]
in conjunction with[L]
(that is, use[R,L]
) because on its own, the[R]
flag prependshttp://thishost[:thisport]
to the URI, but then passes this on to the next rule in the ruleset, which can often result in 'Invalid URI in request' warnings.
现在,假设我有一个重写语句如下:
RewriteRule ^pass/?$ https://www.example.com/ [R,NC]
既然我在这里将我的客户端重定向到另一个主机/域,我真的需要传递 [L]
标志吗?
如果我也使用 [QSA]
标志会有影响吗?
最佳答案
确实是个好问题。
在我所有的测试中,我无法创建一个场景,从该规则中省略 L
会显示整体行为的任何变化。唯一的变化发生在内部,因为放置 L
标志会强制 mod_rewrite
立即运行 rewrite
循环,而不是一直运行到文件末尾。因此,如果不是出于其他原因,IMO 具有 L
是更好的性能原因。
关于QSA
:这里绝对不需要,因为只有在您的规则修改QUERY_STRING
时才需要QSA
> 这里不是这种情况。
关于apache - 重定向到另一台主机时使用 [L] 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25759465/