使用Apache的mod_rewrite时的重写规则秩序的性能影响 [英] performance impact of order of rewrite rules when using apache mod_rewrite

查看:138
本文介绍了使用Apache的mod_rewrite时的重写规则秩序的性能影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我读到有关有时取消显而易见的方法的mod_rewrite的处理,你给它(例如:先读重写规则,然后回过头来检查的RewriteCond)的各种重写规则,但:

while i have read about the 'sometimes un-obvious way' that mod_rewrite handles the various rewrite rules you feed it (eg: first reading RewriteRule, then going back to check RewriteCond), but:

就表现而言,它的规则的顺序有关系吗?

as far as performance is concerned, does the order of the rules matter?

确实在自上而下的方式Apache进程呢?这意味着最常用的规则应在技术上尽可能靠近列表尽可能

does apache process them in a 'top down' way? meaning that the most used rules should technically be as close to the top of the list as possible?

这是不是对重叠的规则等问题,对于这​​个问题,假设所有的规则[L]和非重叠的。

this is not a question regarding overlapping rules etc, for this question assume that all the rules are [L] and non-overlapping.

所以,

应该是最常用的规则尽量靠近顶端越好,而靠近底部较少使用的?

should the most used rules be as close to the top as possible, while the less used ones near the bottom?

谢谢!

推荐答案

从重写规则的文档:

http://httpd.apache.org/docs/current/ MOD / mod_rewrite.html#重写规则

在这些规则的定义的顺序是非常重要的 - 这是他们将在运行时应用的顺序

所以,如果你把你常用的重写规则上方,并尽可能使用标志标记它们,就不会处理规则的休息,你就会有一个优化的配置:

So if you put your common rewrite rules at the top, and whenever possible mark them with the L flag, it won't process the rest of the rules, and you'll have an optimized configuration:

最后| L - 立即停止重写的过程,不施加任何更多的规则

这篇关于使用Apache的mod_rewrite时的重写规则秩序的性能影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆