nginx的location匹配規則

  • 空格:默認匹配,普通匹配
location / { 
    root /home;
}
  • =:精確匹配
location = /imooc/img/face1.png { 
    root /home;
}
  • -*:匹配正則表達式,不區分大小寫
#符合圖片的顯示 location ~ \.(GIF|jpg|png|jpeg) { 
    root /home;
}
  • 〜:匹配正則表達式,區分大小寫
#GIF必須大寫才能匹配到 
location〜\.(GIF|jpg|png|jpeg) {
    root /home;
}
  • ^〜:以某個字符路徑開頭
location ^~ /test/img {
    root /home
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章