匹配以字母 i 开头的 nginx 位置
Matching nginx locations starting with letter i
我在使用以 "i" 开头的位置块时遇到问题。
请求“/”不匹配以下位置块(这是预期结果)
location /h {
return 302 /redirect-for-testing-purposes ;
}
但是另一个以 "i" 开头的是通过请求“/”匹配的
location /i {
return 302 /redirect-for-testing-purposes ;
}
请注意,此行为仅出现在字母 "i" 中,您可以使用以下位置块对其进行测试:
此位置块将不会通过请求“/”进行匹配
location ~* ^/([a-h]|[j-z]) {
return 302 /redirect-for-testing-purposes ;
}
同时这会
location ~* ^/[a-z] {
return 302 /redirect-for-testing-purposes ;
}
这里发生了什么我想不通的事?
谢谢
nginx 版本:1.14.0 和 1.12.1
i
也是index.html
的第一个字母。
当您访问像 /
这样的 URI 时,index
指令会在内部将 URI 重写为 /index.html
.
内部重写后,nginx
将开始另一次搜索匹配的 location
块并找到您的 location /i
块。
有关更多信息,请参阅 this document。
我在使用以 "i" 开头的位置块时遇到问题。
请求“/”不匹配以下位置块(这是预期结果)
location /h {
return 302 /redirect-for-testing-purposes ;
}
但是另一个以 "i" 开头的是通过请求“/”匹配的
location /i {
return 302 /redirect-for-testing-purposes ;
}
请注意,此行为仅出现在字母 "i" 中,您可以使用以下位置块对其进行测试:
此位置块将不会通过请求“/”进行匹配
location ~* ^/([a-h]|[j-z]) {
return 302 /redirect-for-testing-purposes ;
}
同时这会
location ~* ^/[a-z] {
return 302 /redirect-for-testing-purposes ;
}
这里发生了什么我想不通的事? 谢谢
nginx 版本:1.14.0 和 1.12.1
i
也是index.html
的第一个字母。
当您访问像 /
这样的 URI 时,index
指令会在内部将 URI 重写为 /index.html
.
内部重写后,nginx
将开始另一次搜索匹配的 location
块并找到您的 location /i
块。
有关更多信息,请参阅 this document。