十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。
Nginx的location匹配规则
上一篇 /
下一篇 2011-12-24 16:21:38
/ 个人分类:nginx
Nginx的Location可以有以下几个匹配:51Testing软件测试网\Sq ^Q%H)v
1. = 严格匹配这个查询。如果找到,停止搜索。
Q,Z!QoBI D3@02. ^~ 匹配路径的前缀,如果找到,停止搜索。51Testing软件测试网8M0l1h"Z2S-W
3. ~ 为区分大小写的正则匹配
H5t;K9z/}3__m#K04. ~* 为不区分大小写匹配
D_cF YTWT1]L*W0
q|r%G/H%Et0例子:
&O*K6H
TS _IQ051Testing软件测试网.Xw `+@J5J
location = / {
(n C6X"r
P/_R0# matches the query / only.51Testing软件测试网@1o`#l,K"iMV'G
# 只匹配 / 查询。
8N9aI&\3@ga9a0[ configuration A ]
?+LM"c'n}7g4~A#r0}
\-W.i Ti.{#J}0location / {51Testing软件测试网"Uq"Yz,U%bn2t
# matches any query, since all queries begin with /, but regular51Testing软件测试网7G;X$sQ"@$U
# expressions and any longer conventional blocks will be
1hG(Y q'T(b3ma0# matched first.
I `6nX
I]&P [0# 匹配任何查询,因为所有请求都已 / 开头。但是正则表达式规则和长的块规则将被优先和查询匹配。
6y Fn(~2_#N0[ configuration B ]
!`c/?h^s m/b z0}51Testing软件测试网_3y:Ju-`
`8A
location ^~ /images/ {
$gbZia]?0# matches any query beginning with /images/ and halts searching,
l&T