nginx rewrite last和break区别

last 停止rewrite,如果没有匹配到,会继续向下匹配,如果匹配到,会重新发起匹配

break 停止rewrite,如果没有匹配到,则不会向下匹配,返回404

root /www
location /break/ { default_type text/html
; rewrite ^/break/(.*) /test/$1 break; } location /last/ { default_type text/html; rewrite ^/last/(.*) /test/$1 last; return 200 "last page"; } location /test/ { default_type text/html; return 200 "test page"; }

 

对于http://localhost/break/abc.html,如果/www/test目录下不存在abc.html,会返回404错误

对于http://localhost/last/abc.html,会重新发起新请求,去匹配/test/$1即http://localhost/test/abc.html,会返回test page

posted @ 2020-07-15 10:38  宋健安  阅读(441)  评论(0编辑  收藏  举报