实例区分nginx location中rewrite的break与last
2015-03-21 14:52
393 查看
验证代码:
server{
listen 80;
server_name www.example.com;
location ~ /test1.txt {
rewrite /test1.txt /test2.txt break;
#rewrite /test1.txt /test2.txt last;
}
location ~ /test2.txt {
root /var/txt/;
}
}
文件设置:
验证 rewrite /test1.txt /test2.txt break; 在 /usr/local/nginx/html 有test2.txt 内容为 /usr/local/nginx/html/test2
验证 rewrite /test1.txt /test2.txt last; 在/var/txt/ 有test2.txt 内容为 /var/test2
说明:
在使用break时,www.example.com/test1.txt rewrite 为 www.example.com/test2.txt 不向下边的location中查找,我们会查看到 /usr/local/nginx/html/test2,说明是/usr/local/nginx/html中的test2.txt
(last其实就相当于一个新的url,对nginx进行了一次请求,需要走一遍大多数的处理过程,最重要的是会做一次find
config,提供了一个可以转到其他location的配置中处理的机会,)
在使用last时,www.example.com/test1.txt rewrite 为 www.example.com/test2.txt 并匹配下边的location。我们会查看到 /var/test2
(break则是在一个请求处理过程中将原来的url(包括uri和args)改写之后,在继续进行后面的处理,这个重写之后的请求始终都是在同一个location中处理。)
server{
listen 80;
server_name www.example.com;
location ~ /test1.txt {
rewrite /test1.txt /test2.txt break;
#rewrite /test1.txt /test2.txt last;
}
location ~ /test2.txt {
root /var/txt/;
}
}
文件设置:
验证 rewrite /test1.txt /test2.txt break; 在 /usr/local/nginx/html 有test2.txt 内容为 /usr/local/nginx/html/test2
验证 rewrite /test1.txt /test2.txt last; 在/var/txt/ 有test2.txt 内容为 /var/test2
说明:
在使用break时,www.example.com/test1.txt rewrite 为 www.example.com/test2.txt 不向下边的location中查找,我们会查看到 /usr/local/nginx/html/test2,说明是/usr/local/nginx/html中的test2.txt
(last其实就相当于一个新的url,对nginx进行了一次请求,需要走一遍大多数的处理过程,最重要的是会做一次find
config,提供了一个可以转到其他location的配置中处理的机会,)
在使用last时,www.example.com/test1.txt rewrite 为 www.example.com/test2.txt 并匹配下边的location。我们会查看到 /var/test2
(break则是在一个请求处理过程中将原来的url(包括uri和args)改写之后,在继续进行后面的处理,这个重写之后的请求始终都是在同一个location中处理。)
相关文章推荐
- 怎样区别nginx中rewrite时break和last
- Nginx配置的rewrite编写时last与break的区别详解
- nginx rewrite中last和break的区别
- nginx中rewrite模块break和last原理详解
- Nginx中的rewrite指令(break,last,redirect,permanent)
- nginx rewrite break last
- nginx中rewrite模块break和last原理详解
- Nginx配置文件的rewrite功能中break和last的差别
- Nginx中的rewrite指令(break,last,redirect,permanent)
- Nginx配置的rewrite编写时last与break的区别分析
- nginx中rewrite模块break和last原理详解
- Nginx中的rewrite指令(break,last,redirect,permanent)
- Nginx location总结及rewrite规则写法
- ReactiveCocoa比较区分replay, replayLast和replayLazily
- nginx的Rewrite实例–在url最后补全/符号
- 区分Oracle的数据库,实例,服务名,SID
- 一起talk C栗子吧(第一百八十回:C语言实例--break到哪里)
- 4.3.4 区分transient和detached实例
- JS数组filter()、map()、some()、every()、forEach()、lastIndexOf()、indexOf()实例
- nginx中的rewrite用法及实例