MOD_Rewrite 重写是否会调用重写规则的第二次运行?
当 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就你而言,它无论如何都不会循环。 您打开“L”开关,将该特定规则固定为最后一个。
此外,您必须使用“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: