Home >Backend Development >PHP Tutorial >Detailed explanation of nginx location priority location nginx nested location nginx path nginx location roo

Detailed explanation of nginx location priority location nginx nested location nginx path nginx location roo

WBOY
WBOYOriginal
2016-07-29 08:49:555226browse

There are several types of location in

nginx:

1. Prefix, which can be modified with = or ^~, such as

location / /

location /img/ starting with /

location = /a.htm starting with /img/ /a.htm

location ^~ /d No longer checks the regular expression location after matching

2. Regular expression, fixed at the beginning of ~ or ~* (not case-sensitive), such as:

location ~ .html$

location ~* .gif$

When there are multiple locations at the same time, 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.
If a match is prefixed with =, the match ends
3.If the ^~ (caret-tilde) modifier prepends the longest matching prefix string, the regular expressions are not checked.
If the longest match contains ^~, the match ends
4.Store the longest matching prefix string.
Save the longest match
5.Test the URI against regular expressions.
Check again~ Regular expression at the beginning
6.Break on the first matching regular expression and use the corresponding location.
The first matching regular expression, end matching
7.If no regular expression matches, use the location corresponding to the stored prefix string.

If there is no regular match, use the longest prefix just now

The above introduces the detailed explanation of nginx location priority, including location and nginx content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn