nginx location规则

To summarize, the order in which directives are checked is as follows:

1,Directives with the “=” prefix that match the query exactly. If found, searching stops.

2,All remaining directives with conventional strings. If this match used the “^~” prefix, searching stops.

3,Regular expressions, in the order they are defined in the configuration file.

4,If #3 yielded a match, that result is used. Otherwise, the match from #2 is used.

个人总结:

1,普通匹配的表达式不能重复,正则匹配的表达式不能重复(不同的修饰符可以重复,比如~和~*)

2,正则匹配:要有~(大小写敏感)获取~*(大小写不敏感)

普通匹配:^~或=或空

3,最大前缀匹配,uri要尽量匹配更多的前缀

4,普通匹配没有编辑的顺序,正则有

5,正则location让位于=和^~,覆盖其他的普通location

你可能感兴趣的:(nginx location规则)