慕课学习记录_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 ^~ /imooc/img {
        root /home;
    }
posted @ 2020-08-02 18:50  土豆牛贼烦人  阅读(120)  评论(0编辑  收藏  举报