location优先级
location /img # 直接匹配
location /img {
index index.html
}
location = /img # 精确匹配
location = /img {
index index.html
}
location ^~ /img # 前缀匹配
location ^~ /img/ {
index index.html
}
location ~ /img #区分大小写
location ~* /img #不区分大小写
location ~* .(gif|jpg|jpeg)$ {
index index.html
}
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.
注意:
优化等及相对于相同的匹配