Nginx 精确匹配诡异 各位老哥帮忙看看

新手上路,请多包涵

clipboard.png
clipboard.png

各位老哥 都说精确匹配优先级高 为什么是通用匹配匹配到了? 我很郁闷

如果我把通用匹配去掉了 留下精确匹配 浏览器无法找到 直接跳转到nginx欢迎页面

阅读 2.7k
2 个回答

因为你访问的是 /index.html 不是 /

来,看看官网给的说明:
http://nginx.org/en/docs/http...

Let’s illustrate the above by an example:

location = / {
    [ configuration A ]
}

location / {
    [ configuration B ]
}

location /documents/ {
    [ configuration C ]
}

location ^~ /images/ {
    [ configuration D ]
}

location ~* \.(gif|jpg|jpeg)$ {
    [ configuration E ]
}

The “/” request will match configuration A, the “/index.html” request will match configuration B, the “/documents/document.html” request will match configuration C, the “/images/1.gif” request will match configuration D, and the “/documents/1.jpg” request will match configuration E.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题