nginx location

location匹配命令html

~      #波浪线表示执行一个正则匹配,区分大小写
~*    #表示执行一个正则匹配,不区分大小写
^~    #^~表示普通字符匹配,若是该选项匹配,只匹配该选项,不匹配别的选项,通常用来匹配目录
=      #进行普通字符精确匹配
@     #"@" 定义一个命名的 location,使用在内部定向时,例如 error_page, try_filesnginx


location 优先级官方文档正则表达式

  1. Directives with the = prefix that match the query exactly. If found, searching stops.express

  2. All remaining directives with conventional strings, longest match first. If this match used the ^~ prefix, searching stops.ide

  3. Regular expressions, in order of definition in the configuration file.this

  4. If #3 yielded a match, that result is used. Else the match from #2 is used.spa

  1. =前缀的指令严格匹配这个查询。若是找到,中止搜索。orm

  2. 全部剩下的常规字符串,最长的匹配。若是这个匹配使用^前缀,搜索中止。htm

  3. 正则表达式,在配置文件中定义的顺序。rem

  4. 若是第3条规则产生匹配的话,结果被使用。不然,如同从第2条规则被使用。


转载: http://www.nginx.cn/115.html

相关文章
相关标签/搜索