MOD_Rewrite 重写是否会调用重写规则的第二次运行?

发布于 2024-07-07 09:02:59 字数 188 浏览 8 评论 0原文

当 MOD_Rewrite 执行 RewriteRule 时,是否会针对新生成的请求再次执行所有 MOD_Rewrite 规则? 具体在下面的例子中,这会导致循环吗?

RewriteCond Host:  (?:www\.)?mysite\.com
RewriteRule ^(.*)$ $1 [QSA,L]

When a RewriteRule is executed by MOD_Rewrite will all the MOD_Rewrite rules be executed again for the newly generated request? Specifically in the following example, will this cause a loop?

RewriteCond Host:  (?:www\.)?mysite\.com
RewriteRule ^(.*)$ $1 [QSA,L]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

说不完的你爱 2024-07-14 09:02:59

就你而言,它无论如何都不会循环。 您打开“L”开关,将该特定规则固定为最后一个。

此外,您必须使用“N”或“NS”开关显式强制下一次迭代,否则它将仅遍历您的规则文件并在最后一个匹配的规则处停止。 来自文档:

N(下一次迭代)

强制重写引擎修改
规则的目标和重启规则
从头开始检查(所有
修改已保存)。 数量
重新启动受该值的限制
在 RepeatLimit 中指定
指示。 如果超过这个数字
N 标志将被简单地忽略。

NS(同一规则的下一次迭代)

与 N 标志类似,但会重新启动
来自同一规则的规则处理
(即强制重复规则
应用)。 最大数量
单规则迭代由下式给出
RepeatLimit 指令。 但一些
单个规则重复不算数
全局重复次数(即
重复次数限制
N 标志引起的迭代是
与重复次数无关
由 NS 引起)。

In your case, it won't at any rate do a loop. You have the "L" switch on, fixing that particular rule as the last one.

Further, you have to explicitly force the next iteration by using the "N" or "NS" switches, or it will just move through your rule file and stop with the last rule that matches. From the docs:

N (Next iteration)

Forces rewriting engine to modify
rule's target and restart rules
checking from the beginning (all
modifications are saved). Number of
restarts is limited by the value
specified in the RepeatLimit
directive. If this number is exceeded
N flag will be simply ignored.

NS (Next iteration of the same rule)

Works like the N flag but restarts
rules processing from the same rule
(i.e. forces repeat of the rule
application). Maximum number of a
single rule iterations is given by the
RepeatLimit directive. But a number of
a single rule repeats does not count
for the global number of repeats (i.e.
repeats limit for a number of
iterations caused by N flag is
independent of a number of repeats
caused by NS).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文