: This article mainly introduces the nginxrewite command module. if you are interested in the PHP Tutorial, refer to it. Introduction: as a reverse proxy server, nginx sometimes needs to modify the uri in an http request;
Commands contained in the nginx rewrite module
- Break
- If
- Return
- Rewrite
- Rewrite_log
Nginx rewrite module Introduction
The ngx_http_rewrite_module module is used to change request URI using regular expressions, return redirects, and conditionally select tolerations.
There are three main methods,Regular expressionChange the uri and directly return jump 301,302, 404, and 501 errors. modify the uri according to the condition;
Command execution sequence of nginx rewrite module
The commands of this module can appear under server/location, and of course there are if blocks;
- The directives of this module specified on the server level are executed sequentially;
- Repeatedly:
- A location is searched based on a request URI;
- The directives of this module specified inside the found location are executed sequentially;
- The loop is repeated if a request URI was rewritten, but not more than 10 times.
Rewrite command mark
Syntax: rewrite regex replacement [flag];Default: —Context: server, location, if
- 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 direve VE;
- 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.
These four tags are not mandatory. if the [flag] is missing, they are executed sequentially;
Flowchart
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces the nginx rewite command module, including the regular expression content, hope to be helpful to friends who are interested in PHP tutorials.