nginx位置正则表达式,匹配多次 [英] nginx location regex, match multiple times
本文介绍了nginx位置正则表达式,匹配多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在nginx位置正则表达式中多次匹配?
How to match multiple times in nginx location regex ?
似乎 {x,x} 语法永远行不通!
it seems the {x,x} syntax never works!
例如:
location ~ ^/abc/\w{1,3}$ {
...
}
神经病!
推荐答案
您必须引用包含 {
或 ;
字符的位置.
You must quote location which contains {
or ;
characters.
location ~ "^/abc/\w{1,3}$" {
...
}
否则 nginx 将其解析为 location ~ ^/abc/\w { 1, ...
并因语法错误而失败.
otherwise nginx parse it as location ~ ^/abc/\w { 1, ...
and fails with syntax error.
这篇关于nginx位置正则表达式,匹配多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文