101
位置指令在什麼位置觸發?Nginx優先位置
位置指令在什麼位置觸發?Nginx優先位置
例子:
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 ]
}
如果它仍然混亂,here's a longer explanation。
按此順序點亮。
@brablc謝謝,固定。 – 2015-05-11 21:40:03
與它可以幫助你:)https://github.com/detailyang/nginx-location-match-visible – user2228392 2016-08-01 07:33:36
請注意,'/'和'/ documents /'規則匹配請求'/ documents/index.html' ,但後者的規則優先,因爲它是最長的規則。 – 2017-08-13 19:23:29