nginx location
- =:精确匹配(必须全部相等)
- ~:大小写敏感,正则匹配
- ~*:忽略大小写,正则匹配
- ^~:只需匹配uri部分,精确匹配
- @:内部服务跳转,精确匹配
优先级:
- Exact match =
- Forward match ^~ /
- Case sensitive regex ~ /
- Case insensitive regex ~*
- Path match /
规则
精确匹配规则是“最大前缀”.
正则匹配规则是“顺序匹配”,只要匹配到第一个就停止后面的匹配.
通用匹配 “/”最后匹配
nginx rewrite
rewrite ^(.*)$ /other/path/or/server/$1 break;