billfeller.github.io icon indicating copy to clipboard operation
billfeller.github.io copied to clipboard

nginx rewrite flag参数详解

Open billfeller opened this issue 8 years ago • 0 comments

last stops processing the current set of ngx_http_rewrite_module directives and starts a search for a new location matching the changed URI; break stops processing the current set of ngx_http_rewrite_module directives as with the break directive; redirect returns a temporary redirect with the 302 code; used if a replacement string does not start with “http://” or “https://”; permanent returns a permanent redirect with the 301 code.

last: 使用了last 指令,rewrite 后会跳出 location 作用域,重新开始再走一次刚刚的行为。 break:使用了break 指令,rewrite 后不会跳出 location 作用域,它的生命也在这个location中终结。

permanent:301 Moved Permanently redirect:302 Moved Temporarily

总结 last与break对前端是透时的,主要体现在服务器端的处理流程的区别; permanent与redirect则是通过返回3xx给前端从而进行重定向;

如下图显示permanent与redirect在浏览器端的区别: rewrite_301_permanent_302_redirect

推荐阅读:

  1. rewrite regex replacement [flag]
  2. Creating NGINX Rewrite Rules

billfeller avatar Dec 20 '16 03:12 billfeller