本文介绍了Nginx位置优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
带有"="前缀的指令与查询完全匹配.如果找到,搜索将停止.
所有剩余的带有常规字符串的指令.如果此匹配项使用"^〜"前缀,则会停止搜索.
正则表达式,按照它们在配置文件中定义的顺序.
如果#3匹配,则使用该结果.否则,将使用#2中的匹配项.
位置指令按什么顺序触发?
What order do location directives fire in?
推荐答案来自 HttpCoreModule文档:
文档中的示例:
location = / { # matches the query / only. [ configuration A ] } location / { # matches any query, since all queries begin with /, but regular # expressions and any longer conventional blocks will be # matched first. [ configuration B ] } location /documents/ { # matches any query beginning with /documents/ and continues searching, # so regular expressions will be checked. This will be matched only if # regular expressions don't find a match. [ configuration C ] } location ^~ /images/ { # matches any query beginning with /images/ and halts searching, # so regular expressions will not be checked. [ configuration D ] } location ~* \.(gif|jpg|jpeg)$ { # matches any request ending in gif, jpg, or jpeg. However, all # requests to the /images/ directory will be handled by # Configuration D. [ configuration E ] }如果仍然令人困惑,请此处有较长的解释.
If it's still confusing, here's a longer explanation.
更多推荐
Nginx位置优先级
发布评论