1 Location match 1.1 equals match:
=
The Equals match is the equals sign, and the feature can be summed up as two points:
- Exact match
- Regular expressions are not supported
1.2 Null match character
The characteristics of an empty match are:
- Matches the URI starting with the specified pattern
- Regular expressions are not supported
1.3 Regular Match characters:
~
A regular match is a match that can be used with regular expressions. However, it should be emphasized that, in general, ~
it means:
区分大小写的正则匹配
and ~*
said:
不区分大小写的正则匹配
But for some operating systems that are not case sensitive, there is no difference between the two. The other is ^~
that it represents a regular match that starts with the specified pattern.
1.4 Internal accessors:
@
Commonly used for error pages, etc., this is not discussed.
2 match-Break precedence
=
- Null match, when exact match is met
- ^~
~
Or~*
- An empty match that satisfies the match at the beginning of the specified pattern
This is more abstract, let's take a look at an example.
2.1 Equals an empty match between match and exact match
Take a look at the following example (using the module we completed together previously Hello World
):
location/poechant {Hello_world no1;} Location =/poechant {Hello_world no2;}
If our request is http://my.domian/poechant
, we found two location
is matched to the requested URI, and according to our priority order, the first is an empty match when the exact match is matched, the second equals the match, so the second priority is high, which is the output:
hello_world, no2
It also indicates that Nginx's locatoin is not matched according to the order of writing in the configuration file.
2.2 The exact match of an empty match with a regular match
^~
In the following example, both begin to match exactly, and even this regular match is exact match.
location ^~ ^/poechant$ { hello_world no1;}location /poechant { hello_world no2;}
Which one does it match? You test it and you get:
hello_world, no2
is consistent with the order of precedence that we have mentioned above.
2.3 Instances of other matching priority comparisons
Slightly
-
Research on the configuration and deployment of high performance Web server Nginx (16) Location matching mode priority