- 浏览: 400182 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
wcjagta:
...
dedecms插件开发教程 -
xc2013:
看起来不错 先下载来试试
ECSHOP完全静态化解决方法 -
greemranqq:
你好,我在xp 上做实验,也是JS css带不过来,关于 ro ...
nginx资源定向 css js路径问题 -
hotsmile:
表结构给出来吧,测试的提示说要注册,
中国移动CMPP短信开发平台通讯包 2.8 -
mengdejun:
gang80306176 写道这个插件怎么用和安装普通插件一样 ...
phpcms2008 sp4单网页编辑器插件
location
syntax: location [=|~|~*|^~] /uri/ { … }
语法:location [=|~|~*|^~] /uri/ { … }
default: no
默认:否
context: server
上下文:server
This directive allows different configurations depending on the URI. It can be configured using both conventional strings and regular expressions. To use regular expressions, you must use the prefix ~* for case insensitive match and ~ for case sensitive match.
这个指令随URL不同而接受不同的结构。你可以配置使用常规字符串和正则表达式。如果使用正则表达式,你必须使用 ~* 前缀选择不区分大小写的匹配或者 ~ 选择区分大小写的匹配。
To determine which location directive matches a particular query, the conventional strings are checked first. Conventional strings match the beginning portion of the query and are case-sensitive – the most specific match will be used (see below on how nginx determines this). Afterwards, regular expressions are checked in the order defined in the configuration file. The first regular expression to match the query will stop the search. If no regular expression matches are found, the result from the convention string search is used.
确定 哪个location 指令匹配一个特定指令,常规字符串第一个测试。常规字符串匹配请求的开始部分并且区分大小写,最明确的匹配将会被使用(查看下文明白 nginx 怎么确定它)。然后正则表达式按照配置文件里的顺序测试。找到第一个比配的正则表达式将停止搜索。如果没有找到匹配的正则表达式,使用常规字符串的结果。
There are two ways to modify this behavior. The first is to use the prefix “=”, which matches an exact query only. If the query matches, then searching stops and the request is handled immediately. For example, if the request “/” occurs frequently, then using “location = /” will expedite the processing of this request.
有两个方法修改这个行为。第一个方法是使用 “=”前缀,将只执行严格匹配。如果这个查询匹配,那么将停止搜索并立即处理这个请求。例子:如果经常发生”/”请求,那么使用 “location = /” 将加速处理这个请求。
The second is to use the prefix ^~. This prefix is used with a conventional string and tells nginx to not check regular expressions if the path provided is a match. For instance, “location ^~ /images/” would halt searching if the query begins with /images/ – all regular expression directives would not be checked.
第二个是使用 ^~ 前缀。如果把这个前缀用于一个常规字符串那么告诉nginx 如果路径匹配那么不测试正则表达式。
Furthermore it is important to know that NGINX does the comparison not URL encoded, so if you have a URL like “/images/%20/test” then use “/images/ /test” to determine the location.
而且它重要在于 NGINX 做比较没有 URL 编码,所以如果你有一个 URL 链接’/images/%20/test’ , 那么使用 “images/ /test” 限定location。
To summarize, the order in which directives are checked is as follows:
总结,指令按下列顺序被接受:
1. Directives with the = prefix that match the query exactly. If found, searching stops.
1. = 前缀的指令严格匹配这个查询。如果找到,停止搜索。
2. All remaining directives with conventional strings, longest match first. If this match used the ^~ prefix, searching stops.
2. 剩下的常规字符串,长的在前。如果这个匹配使用 ^~ 前缀,搜索停止。
3. Regular expressions, in order of definition in the configuration file.
3. 正则表达式,按配置文件里的顺序。
4. If #3 yielded a match, that result is used. Else the match from #2 is used.
4. 如果第三步产生匹配,则使用这个结果。否则使用第二步的匹配结果。
Example:
例子:
location = / {
# matches the query / only.
# 只匹配 / 查询。
[ configuration A ]
}
location / {
# matches any query, since all queries begin with /, but regular
# expressions and any longer conventional blocks will be
# matched first.
# 匹配任何查询,因为所有请求都已 / 开头。但是正则表达式规则和长的块规则将被优先和查询匹配。
[ configuration B ]
}
location ^~ /images/ {
# matches any query beginning with /images/ and halts searching,
# so regular expressions will not be checked.
# 匹配任何已 /images/ 开头的任何查询并且停止搜索。任何正则表达式将不会被测试。
[ configuration C ]
}
location ~* \.(gif|jpg|jpeg)$ {
# matches any request ending in gif, jpg, or jpeg. However, all
# requests to the /images/ directory will be handled by
# Configuration C.
# 匹配任何已 gif、jpg 或 jpeg 结尾的请求。然而所有 /images/ 目录的请求将使用 Configuration C。
[ configuration D ]
}
Example requests:
例子请求:
*
/ -> configuration A
*
/documents/document.html -> configuration B
*
/images/1.gif -> configuration C
*
/documents/1.jpg -> configuration D
Note that you could define these 4 configurations in any order and the results would remain the same.
注意:按任意顺序定义这4个配置结果将仍然一样。
发表评论
-
php异步操作类库
2011-06-05 16:01 1777httpclient for php 的选择常用方案有以 ... -
织梦HTTP IMAGE下载类
2011-06-05 14:57 1850<?php if(!defined('DEDEINC ... -
php汉字转拼音
2011-06-05 14:41 1569<?php /**************** ... -
PHP采集利器:Snoopy 试用心得
2011-06-05 14:34 14015Snoopy是一个php类,用 ... -
php异步调用 提高用户体验
2011-05-30 14:22 1288这是我的一个技术很好的朋友写的,要我发表在我的博客上可让php ... -
PHP 异步调用 后台调用 持续执行 断开连接/浏览器
2011-05-26 10:31 1676标题很怪,因为我也 ... -
php socket模拟POST GET请求 fsockopen版
2011-05-26 10:14 7338function httpRequestGET($url){ ... -
php socket GET POST提交方法(HttpClient) 框架
2011-05-25 18:29 5511<?php /* Version 0.9, 6th ... -
mantis
2011-05-25 09:50 1246mantis 缺陷管理平台Mantis,也做Mantis ... -
Curl参数一览
2011-05-06 17:30 1444* 目录 1. 介绍 ... -
PHPRPC
2011-04-24 11:01 1286PHPRPC 是一个轻型的、安全的、跨网际的、跨语言的、跨平台 ... -
PHP身份证验证程序
2011-04-24 10:56 1239<?php // 计算身份证校验码,根据国家标准GB 116 ... -
nginx 502 Bad Gateway 错误问题收集
2011-04-23 09:43 1722502是FastCGI出现问题,所以从FastCGI配置入手。 ... -
深入理解PHP内存管理之谁动了我的内存
2011-04-12 21:57 824首先让我们看一个问题: ... -
socket模拟post表单
2011-04-11 15:40 2767post的本质就是发送给目的程序一个标志为post的协议串如下 ... -
OAUTH协议
2011-04-09 09:59 1060OAUTH协议为用户资源的 ... -
nginx/windows: 让nginx以服务的方式运行
2011-04-09 09:33 1122在windows下安装了nginx, 郁闷是发现它没有以服 ... -
ThinkPHP处理海量数据分表机制详细代码
2011-04-07 18:27 7168应用ThinkPHP内置的分表算法处理百万级用户数据. ... -
php 分库分表hash算法
2011-04-07 18:16 1669//分库分表算法 function calc_hash_d ... -
nginx配置文件实例: php (fastcgi), perl, proxy, rrd, nagios
2011-04-06 20:33 1799nginx.conf worker_processes 5; ...
相关推荐
主要介绍了Nginx Location 指令简明指南,本文讲解了它的基本语法、匹配过程、配置实例和全局变量,需要的朋友可以参考下
Nginx配置指令location匹配符优先级和安全问题详解Nginx location 匹配规则Nginx服务器的location指令匹配规则详解利用nginx如何匹配多个条件Nginx ...location匹配规则nginx 匹配规则小总结(推荐)Nginx Location指令URI匹
Nginx 中的 Location 指令 是NginxHttpCoreModule中重要指令。Location 指令,是用来为匹配的 URI 进行配置,URI 即语法中的”/uri/”,可以是字符串或正则表达式。但如果要使用正则表达式,则必须指定前缀。 nginx ...
主要介绍了Nginx Location指令URI匹配规则详解小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Nginx 中的 Location 指令 是NginxHttpCoreModule中重要指令。Location 指令,是用来为匹配的 URI 进行配置,URI 即语法中的”/uri/”,可以是字符串或正则表达式。但如果要使用正则表达式,则必须指定前缀。 nginx ...
1、首先我们回顾一下nginx中location的相关知识 1)location的匹配指令: ~ #波浪线表示执行一个正则匹配,区分大小写 ~* #表示执行一个正则匹配,不区分大小写 ^~ #^~表示普通字符匹配,不是正则匹配。如果该...
解决这个问题,第一的反映是直接使用 Nginx 的 location 指令来解决,不过在给出答案之前,我们先来了解一下 Nginx location 指令的基础。 Nginx 区块配置概念 在 Nginx 的配置文件中,通常会用两个常用的区块...
root 指令只是将搜索的根设置为 root 设定的目录,即不会截断 uri,而是使用原始 uri 跳转该目录下查找文件 aias 指令则会截断匹配的 uri,然后使用 alias 设定的路径加上剩余的 uri 作为子路径进行查找 location ...
3.4. nginx重要指令之location 4. nginx中的rewrite 4.1. 什么是rewrite 4.2. rewrite的命令的作用域和优先级 4.3. if指令 4.3.1. if指令的语法 4.3.2. if指令中使用的逻辑运算符 4.3.3. If指令中可以使用的...
本文详细讲述了Nginx location正则写法,Nginx 的Rewrite规则以及Nginx.conf中if指令与全局变量
最近一直在做location 配置,遇到优先级别问题(如果配置不当可能存在安全隐患哦),以下是个人学习一点体会。 一、 location 的匹配符1.等于匹配符:=等于匹配符就是等号,特点可以概括为两点:精确匹配不支持正则...
内容:详解Nginx的主模块中,测试时经常使用的指令。 7、高性能Web服务器Nginx的配置与部署研究(7)核心模块之主模块的非测试常用指令 内容:详解Nginx的主模块中,非测试常用指令的使用方式。 8、高性能Web...
背景介绍 最近在个人的多个项目部署中遇到这样一个问题,一个域名如何实现多个项目的访问。...2.普通字符串指令匹配,顺序是从长到短,匹配成功的location如果使用^~,则停止其他匹配(正则匹配)。 3.正则表达式指
location ~* \.(gif|jpg|png|webp)$ { valid_referers none blocked domain.com *.domain.com server_names ~\.google\. ~\.baidu\.; if ($invalid_referer) { return 403; #rewrite ^/ ...
Bugfix:如果将"break"指令与"alias"指令或带有 URI 的"proxy_pass"指令一起使用,则可能在 worker 进程中发生分段错误 Bugfix:如果请求 URI 被重写为包含空字符的 URI,则"Location"的响应 header 行可能包含垃圾...