Nginx Location Priority detailed location Nginx nested location nginx path Nginx location Roo

Source: Internet
Author: User
There are several types of Nginx location:

1. prefix, can have = or ^~ modification, for example

Location//start of

location/img//img/the beginning of the

Location =/a.htm just/a.htm

Location ^~/d matches no longer checks for regular expression location

2. Regular expressions, fixed ~ or ~* (case-insensitive) start with, for example:

Location ~ \.html$

Location ~* \.gif$

When there are multiple location, the priority is as follows:

1.Test the URI against all prefix strings.

Compare with all prefixes
2.The = (equals sign) modifier defines an exact match of the URI and a prefix string. If The exact match is found, the search stops.
A match prefix has =, then the match is ended
3.If the ^~ (caret-tilde) modifier prepends the longest matching prefix string, the regular expressions is not checked.
Longest match with ^~ to end match
4.Store the longest matching prefix string.
Save longest match
5.Test the URI against regular expressions.
Re-check the regular expression at the beginning of the ~
6.Break on the first matching regular expression and use the corresponding location.
First matched regular expression, ending match
7.If no regular expression matches, use the location corresponding to the stored prefix string.

If there is no regular match, the longest prefix is used

The above describes the Nginx location priority in detail, including the location,nginx aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.