相信資訊如下:http://nginx.org/en/docs/http/ngx_http_core_module.html#location
location 的文法比對的格式:
location [=|~|~*|^~] patt {
}
location = patt {} [精準比對]
location patt{} [一般比對]
location ~ patt{} [正則比對]
1、 比對的規則為:
先去比對精準比對,如果精辟比對不成功則會去比對一般比對,再次為正則比對。
比對執行個體為:
1) 精準比對
location = / {
root html;
index a.html index.html index.htm;
}
2) 一般比對
location =/ {
root html;
index a.html index.html index.htm;
}
3)、 正則比對
location ~ image {
root /var/www/;
index index.html;
}
4) 正則比對
location / image {
root /var/www/;
index index.html;
}
注意 : 1)、 ~ image 正則比對時會把image目錄帶上,在root把最後的image的目錄去掉。
正則比對時比對上第一個就會傳回。
2) 在一般比對時比對記憶最長的結果