nginx的多个location都匹配到了请求,那么怎么知道具体走的是哪个location?
有没有什么日志可以打印出来是哪个location匹配的?
`
location ^~ /test {
rewrite ^/test/(.*) /test/aaa/$1;
}
location ^~ /test/a2 {
rewrite ^/test/(.*) /test/aaa/$1;
}
`
类似以上的,访问 http://xx/test/a2/xxx ,日志中怎么打印是走的哪个location呢?
###你这个location是普通匹配,普通匹配的话,优先级是最长。location ^~ /test/a2
为了验证这个,你可以在日志中验证。
首先你需要开启两个配置,在server里面定义:
1.设置下error_log的等级
error_log logs/error.log notice;
2.开启重写的日志输出设置
rewrite_log on;