Scenario advantages: URL access redirection, compatible support, SEO optimization, background maintenance, traffic forwarding, safe
Syntax:
Syntax: rewrite regex (regex式) replacement [flag];
Context: server,location, if
For example, maintenance interface
rewrite ^(.* )$ /pages/maintain.html break;
flag:
last stop detection A new request will be created
break stop detection No new request will be created, first make sure the request exists
redirect returns to 302 temporary redirection, the address bar shows the address after the jump
permanent returns to 301 permanent redirection , The address bar shows the address after the jump
The difference between last and break
redirect Difference from last
< p>The client will create a temporary 302 request target before the /test/ request /test/ There are 2 requests in response
Last will have one request
permanent
After nginx is stopped, the requested interface will also be cached in the browser< /p>
redirec t It is only a temporary cache, and it will be slower to request again
Some common configurations