zoukankan      html  css  js  c++  java
  • nginx location标签的匹配规则



    location的匹配


    匹配符 匹配规则 优先级
    = 精确匹配 1
    ^~ 以某个字符串开头 2
    ~ 区分大小写的正则匹配 3
    ~* 不区分大小写的正则匹配 4
    !~ 区分大小写不匹配的正则 5
    !~* 不区分大小写不匹配的正则 6
    / 通用匹配,任何请求都会匹配到 7
    # 通用匹配,任何请求都会匹配到
    location / {
            default_type text/html;
            return 200 "访问到了 /";
    }
     
    # 严格区分大小写,匹配以.php结尾的都走这个location    
    location ~ .php$ {
            default_type text/html;
            return 200 "访问到了 php结尾的文件";    
    }
     
    # 严格区分大小写,匹配以.jsp结尾的都走这个location 
    location ~ .jsp$ {
            default_type text/html;
            return 200 "访问到了 .jsp结尾的文件";   
    }
     
    # 不区分大小写匹配,只要用户访问.jpg,gif,png,js,css 都走这条location
    location ~* .(jpg|gif|png|js|css)$ {
            default_type text/html;
            return 200 "访问到了 .jpg结尾的文件";   
    }
     
    # 不区分大小写匹配
    location ~* ".(sql|bak|tgz|tar.gz|.git)$" {
            default_type text/html;
            return 200 "访问到了 .tar.gz结尾的文件";   
    }
    



    FBI WARNING

    QQ:1402122292 认准原创sheldon 别人叫我晓东
  • 相关阅读:
    RabbitMQ 集群与高可用配置
    ManifoldJS
    Top JavaScript Frameworks, Libraries & Tools and When to Use Them
    AngularJS 的安全Apply
    node js 常用模块
    微软发布了ASP.NET WebHooks预览版
    leaflet 了解
    messagepcak 资料
    fastBinaryJSON
    jQuery的图像裁剪插件Jcrop
  • 原文地址:https://www.cnblogs.com/gshelldon/p/13301242.html
Copyright © 2011-2022 走看看