nginx.conf configuration location
location matching command
~ #The wavy line indicates performing a regular match, case-sensitive
~* # means performing a regular match, case-insensitive
^~ #^~ means normal character matching. If this option matches, only this option will be matched and other options will not be matched. It is generally used to match directories
= #Perform exact matching of common characters
@ #"@" defines a named location, used when directed internally, such as error_page, try_files
location matching priority (regardless of the order of location in the configuration file)
= Exact matches will be processed first. If an exact match is found, nginx stops searching for other matches.
Ordinary character matching, regular expression rules and long block rules will be prioritized and matched against the query. That is to say, if the item matches, you need to check whether there is a regular expression match or a longer match.
^~ will only match this rule, and nginx will stop searching for other matches, otherwise nginx will continue to process other location instructions.
The final matching method contains instructions with "~" and "~*". If a corresponding match is found, nginx stops searching for other matches; when there is no regular expression or no regular expression is matched, then the one with the highest degree of matching Verbatim matching directives will be used.
<code>location = / { <span># </span>只匹配<span>"/"</span>. [ configuration A ] } location / { <span># </span>匹配任何请求,因为所有请求都是以<span>"/"</span>开始 <span># </span>但是更长字符匹配或者正则表达式匹配会优先匹配 [ configuration B ] } location ^~ /images/ { <span># </span>匹配任何以 /images/ 开始的请求,并停止匹配 其它location [ configuration C ] } location ~* .(gif|jpg|jpeg)$ { <span># </span>匹配以 gif, jpg, or jpeg结尾的请求. <span># </span>但是所有 /images/ 目录的请求将由 [Configuration C]处理. [ configuration D ] }</code>
The above has introduced nginx 2, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.