详解 Nginx 的 Location 配置

203次阅读
没有评论

官方文档:https://nginx.org/en/docs/http/ngx_http_core_module.html#location

Syntax:	location [ = | ~ | ~* | ^~ ] uri { ... }
        location @name { ... }
Default: —
Context: server, location
  • 匹配 URI 类型,有四种参数可选,当然也可以不带参数。
  • 命名 location,用 @ 符号来标识,
参数 解释
= 用于标准 URI 前,要求请求字符串与其精准匹配,成功则立即处理,nginx停止搜索其他匹配。
~ 用于正则 URI 前,表示 URI 包含正则表达式, 区分大小写
~* 用于正则 URI 前, 表示 URI 包含正则表达式, 不区分大小写
^~ 用于标准 URI 前,并要求一旦匹配到就会立即处理,不再去匹配其他的那些个正则 URI,一般用来匹配目录
正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2024-07-06发表,共计364字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)