Answers:
文档中的示例:
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 ]
}
如果仍然令人困惑,这里有一个更长的解释。
/
和/documents/
规则都与request匹配/documents/index.html
,但是后一个规则是优先的,因为它是最长的规则。
它按此顺序触发。
=
(究竟)
location = /path
^~
(前场比赛)
location ^~ /path
~
(正则表达式区分大小写)
location ~ /path/
~*
(正则表达式不区分大小写)
location ~* .(jpg|png|bmp)
/
location /path