Nginxrewite Command Module

Source: Internet
Author: User
: 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.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.