location [=|$|最长原则|^~](nginx-1.4.4)
2016-07-20 15:40
567 查看
优先级由上到下依次递减:
注意:跟位置没并系!!!
NB结论:(从右匹配!!!!)
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/ 优先于 / .
相关文章推荐
- nginx,php相关
- 使用nginx搭建一个简单的负载均衡
- nginx 对多进程进行负载均衡(通过线程池来判断)
- nginx配置
- 使用springmvc 和nginx 搭建一个文件上传下载服务器
- nginx的fastcgi配置信息
- Gerrit+(nginx/Apache) 的git CodeReview平台
- NGINX 结合 lua 动态修改upstream
- Nginx+phpfastcgi下flush输出问题
- nginx.conf详解
- centos 编译安装nginx
- nginx学习
- Nginx之location 匹配规则详解
- 安装nginx
- contos安装php+nginx
- Nginx系统学习篇(1)--基础概念
- 张宴的博客nginx+php+mysql搭建篇
- nginx安装与配置
- Nginx概念及基础安装--详细讲解
- 【CDP-云设计模式】第4章,7.改写代理模式(Rewrite Proxy Pattern)