国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Nginx路徑匹配規(guī)則小結(jié)

瀏覽:122日期:2023-06-15 15:23:36
目錄
  • 1.路徑配置的分類
  • 2.例子

1.路徑配置的分類

在nginx中,一共有4種不同的路徑配置方法

= - Exact match
^~ - Preferential match
~ && ~* - Regex match
no modifier - Prefix match

#路徑完全一樣則匹配
location = path {
}

#路徑開頭一樣則匹配
location ^~ path{
}

#正則匹配,大小寫敏感
location ~ path{
}

#正則匹配,大小寫不敏感
location ~* path{
}

#前綴匹配
location path{
}

上面的執(zhí)行順序是,優(yōu)先查看Exact match,若存在,則停止。如不存在,則進入Preferential match。之后在進入Regex match,先看大小寫敏感的規(guī)則,再看大小寫不敏感的規(guī)則.最后進入Prefix match.

= --> ^~ --> ~ --> ~* --> no modifier

在每一個同類型的匹配規(guī)則中,按照他們出現(xiàn)在配置文件中的先后,一一對比。

2.例子

location /match {  
  return 200 "Prefix match: will match everything that starting with /match";  
}  
  
location ~* /match[0-9] {  
  return 200 "Case insensitive regex match";  
}  
  
location ~ /MATCH[0-9] {  
  return 200 "Case sensitive regex match";  
}  
  
location ^~ /match0 {  
  return 200 "Preferential match";  
}  
  
location = /match {  
  return 200 "Exact match";  
}  

/match     # => 'Exact match'  
/match0    # => 'Preferential match'  
/match1    # => 'Case insensitive regex match'  
/MATCH1    # => 'Case sensitive regex match'  
/match-abc # => 'Prefix match: matches everything that starting with /match'  

到此這篇關(guān)于Nginx路徑匹配規(guī)則小結(jié)的文章就介紹到這了,更多相關(guān)Nginx路徑匹配內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: Nginx
主站蜘蛛池模板: 尼勒克县| 鄂伦春自治旗| 仙游县| 鄄城县| 平乐县| 兴文县| 天柱县| 本溪市| 沅江市| 长垣县| 云浮市| 锡林郭勒盟| 尼玛县| 集贤县| 东光县| 遵义市| 绍兴县| 阿克| 蓬莱市| 荆门市| 吉安市| 蒙阴县| 巴青县| 汶川县| 尖扎县| 璧山县| 莱西市| 遵义市| 洪湖市| 东丰县| 泸水县| 云龙县| 灵石县| 辽中县| 德化县| 武平县| 齐齐哈尔市| 阿图什市| 长丰县| 汉沽区| 商城县|