zoukankan      html  css  js  c++  java
  • location [=|$|最长原则|^~](nginx-1.4.4)

    优先级由上到下依次递减:

    location =/a/1.png {
            return 400;
            }
    
            }
            location ~* .png$ {
            return 403;
            }
    
            location /a/1.png {
            return 401;
            }
    
            location ^~ /a/ {
            return 402;
            }#^~表示普通字符匹配,如果该选项匹配,只匹配该选项,不匹配别的选项,一般用来匹配目录
    
            location /a/ {
            return 404;
            }
    不测和上面402同时开启(会有充突)优先级无法比较!
    
     location / {
            return 500;
            }
    #它的优先级别最低!
    

     注意:跟位置没并系!!!

    server {
            listen       80;
            server_name  localhost;
            index index.html index.htm index.php;
            root /app/www/;
            location / {
            return 500;
            }
            location /a/ {
            return 404;
            }
    #       location ^~ /a/ {
    #       return 402;
    #       }
            location /a/1.png {
            return 401;
            }
            location =/a/1.png {
            return 400;
            }
            location ~* .png$ {
            return 403;
            }
            include /app/server/nginx/conf/rewrite/default.conf;
            access_log  /app/log/nginx/access/default.log;
    }
    

     NB结论:(从右匹配!!!!)

    结论:比较有意思是:/a/ 与 /  应该是 同种类型的匹配表达式, 可以从中得到,该匹配顺序是,将路径从“右匹配“, 可以推测形如逐个字符,那个先匹配到,就是那个优先。 因此得到是:/a/ 优先于 / .
    
  • 相关阅读:
    线程中死锁的demo
    发布.net core程序碰到的问题
    .net core Identity学习(三) 第三方认证接入
    .net Identity学习(二)OAuth
    .net core Identity学习(一)注册登录
    Git常用操作
    log4net使用
    c#中的Quartz
    jquery中的deferred
    .net core应用部署在IIS上
  • 原文地址:https://www.cnblogs.com/bass6/p/5688571.html
Copyright © 2011-2022 走看看