2

nginx的location匹配规则和顺序

 2 years ago
source link: https://www.wencst.com/archives/1949
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

nginx的location匹配规则和顺序

作者: wencst 分类: linux,架构设计 发布时间: 2020-01-16 16:20 阅读: 1,140 次

精准匹配>模糊匹配

匹配多的>匹配少的

(location =) > (location 完整路径) > (location ^~ 路径) > (location ~,~* 正则顺序) > (location 部分起始路径) > (/)

location = /uri    =开头表示精确匹配,只有完全匹配上才能生效。
location ^~ /uri   ^~ 开头对URL路径进行前缀匹配,并且在正则之前。
location ~ pattern  ~开头表示区分大小写的正则匹配。
location ~* pattern  ~*开头表示不区分大小写的正则匹配。
location /uri     不带任何修饰符,也表示前缀匹配,但是在正则匹配之后,如果没有正则命中,命中最长的规则。
location /      通用匹配,任何未匹配到其它location的请求都会匹配到,相当于switch中的default。

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)

Leave a Reply Cancel reply

You must be logged in to post a comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK