performance impact of order of rewrite rules when using apache mod_rewrite

前端 未结 2 832
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-20 19:41

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 ch

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 20:10

    From the documentation for RewriteRule:

    http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

    The order in which these rules are defined is important - this is the order in which they will be applied at run-time.

    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:

    last|L - Stop the rewriting process immediately and don't apply any more rules

提交回复
热议问题