关于nginx位置优先级的混淆
例如:关于nginx位置优先级的混淆,nginx,Nginx,例如: location /images/a/ { return 200; } location ~ \/images\/a\/test\.png$ { return 502; } location ^~ /images/{ return 501; } 我的困惑是,当我访问时,响应代码是502而不是501,来自: nginx首先搜索由文字字符串给出的最具体的前缀位置,而不考虑列出的顺序 因此,选择的前缀位置是location/images/a/。由于
location /images/a/ {
return 200;
}
location ~ \/images\/a\/test\.png$ {
return 502;
}
location ^~ /images/{
return 501;
}
我的困惑是,当我访问时,响应代码是502而不是501,来自:
nginx首先搜索由文字字符串给出的最具体的前缀位置,而不考虑列出的顺序
因此,选择的前缀位置是location/images/a/
。由于此位置未使用^ ~
修饰符标记,因此将按顺序处理正则表达式位置,直到找到匹配项