nginx location语法规则:location [=|~|~*|^~] /uri/ { … }
nginx的location匹配的变量是$uri
规则优先级
= 高于 ^~ 高于 ~* 等于 ~ 高于 /
规则示例
location = "/12.jpg" { ... } 如: www.aminglinux.com/12.jpg 匹配 www.aminglinux.com/abc/12.jpg 不匹配 location ^~ "/abc/" { ... } 如: www.aminglinux.com/abc/123.html 匹配 www.aminglinux.com/a/abc/123.jpg 不匹配 location ~ "png" { ... } 如: www.aminglinux.com/aaa/bbb/ccc/123.png 匹配 www.aminglinux.com/aaa/png/123.html 匹配 location ~* "png" { ... } 如: www.aminglinux.com/aaa/bbb/ccc/123.PNG 匹配 www.aminglinux.com/aaa/png/123.html 匹配 location /admin/ { ... } 如: www.aminglinux.com/admin/aaa/1.php 匹配 www.aminglinux.com/123/admin/1.php 不匹配