Let's talk about the difference first
Nginx configuration file server { listen 88; server_name _; location /break { # location 1 rewrite ^/break/(.*)$ /bak/$1 break; } location /last { # location 2 rewrite ^/last/(.*)$ /bak/$1 last; } location /bak { # location 3 default_type text/html; return 200 $uri; } } Visit http://rumenz.com:88/break/one When location1 is hit, the browser address bar does not change. It goes directly to find the /nginx/html/bak/one file. Since there is no such file, 404 is returned. Browser Nginx error (error.log) log /nginx/html/bak/one failed (2: No such file or directory) break means stop after rewriting and no longer match the location block. Visit http://rumenz.com:88/last/one Hit location2, the browser address bar does not change, re-match to location3 last means to jump to the location block after rewriting and match it with the rewritten address again Use cases for break and last break File download, hide and protect the real file server. location /down { rewrite ^/down/(.*)$ https://rumenz.com/file/$1 break; } last Rewrite the interface address, rewrite https://rumenz.com/api/list to https://rumenz.com/newapi/list location /api { rewrite ^/api/(.*)$ /newapi/$1 last; } location /newapi { default_type Application/json; return 200 '{"code":200,"msg":"ok","data":["JSON.IM","json format"]}'; } Summarize This is the end of this article about the difference between break and last in Nginx. For more information about the difference between break and last in Nginx, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Vue's detailed code for implementing the shuttle box function
>>: How to distinguish MySQL's innodb_flush_log_at_trx_commit and sync_binlog
This article mainly focuses on the installation a...
Text Shadow text-shadow: horizontal offset vertic...
Docker Installation curl -fsSL https://get.docker...
Today I made a Spring Festival gold coin red enve...
1. Download MySQL Workbench Workbench is a graphi...
1. v-on event monitoring To listen to DOM events,...
concept MMM (Master-Master replication manager fo...
Preface Mobile devices have higher requirements f...
List style properties There are 2 types of lists ...
When we want to use a new CSS feature, we always ...
1. Docker mounts the local directory Docker can s...
Supervisor Introduction Supervisor is a client/se...
Let’s learn together 1. Traditional methods Copy ...
Table of contents Introduction The following is a...
Table of contents defineComponent overload functi...