繁体   English   中英

^和$在nginx.conf位置做什么?

[英]What does ^ and $ do in nginx.conf location?

location ~ ^/test/(?<id>\d+)$ {
    postgres_pass    database;
    rds_json         on;
    postgres_escape  $name $id;
    postgres_query   "SELECT $name";
}

上面的代码片段取自https://github.com/FRiCKLE/ngx_postgres/issues/4

有人可以向我解释^做什么以及$做什么? 我找不到解释它的文档。 已经检查过https://github.com/FRiCKLE/ngx_postgreshttp://nginx.org/en/docs/http/ngx_http_core_module.html#location

这是一个正则表达式。 Google正则表达式。

^匹配字符串的开头, $匹配结束。 换句话说,只有当^$之间的部分匹配所有location的值时,此正则表达式才匹配。 因此,只有以/test/开头,后跟一个或多个数字和字符串结尾的URL才匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM