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
1. Download Download address: https://dev.mysql.c...
WeChat Mini Program Component Design Specificatio...
Create a folder Directory structure: dabaots Init...
First, you can open Moments and observe several l...
When we are writing a page, we often encounter a ...
HTML Design Pattern Study Notes This week I mainl...
MySQL is an open source, small relational databas...
The office needs Ubuntu system as the Linux devel...
This article introduces the flex layout to achiev...
In this post, we’ll use the :placeholder-shown ps...
Each of these 16 sites is worth reading carefully,...
Table of contents 1. v-text (v-instruction name =...
I am going to review Java these two days, so I wr...
Table of contents Method 1: The simplest way to s...
1. Download mysql-8.0.17-winx64 from the official...