Nginx中location
来源:互联网 发布:pp助手for mac 编辑:程序博客网 时间:2024/06/08 08:46
location
匹配规则
~ 表示执行一个正则匹配,区分大小写
~* 表示执行一个正则匹配,不区分大小写
^~ 表示普通字符匹配,一旦匹配则不会再去匹配其他,一般用于匹配目录
= 进行普通字符精确匹配
@ 定义一个命名的location,使用内部定向时,例如error_page
优先级
如果使用了=号,则匹配到普通字符就停止匹配其他;
然后其他没有使用=号的常规字符,进行最长匹配;
如果匹配使用了^~,则停止匹配其他;
正则表达式是依照配置文件中的顺序进行匹配的;
如果没有正则表达式或者正则表达式没有被匹配的情况下,则匹配程度最高的逐字匹配指令会被使用
location 实例
1、=
location = / {
root html;
index index.html;
allow all;
}
这样是能只匹配/文件的(可以将allow改成deny测试),所以会找不到index.html文件,下面可以正常访问
location = /index.html {
root html;
index index.html;
allow all;
}
=用于普通字符的精确匹配。要匹配目录不建议使用=
2、^~
location ^~ / {
root html;
index index.html;
allow all;
}
能够匹配到以/开始的请求,停止匹配其他location
^~用于匹配目录
3、~*
location ~* .png$ {
root /usr/share/nginx/test10;
}
- nginx中location介绍
- Nginx中location
- nginx中location配置说明
- nginx配置中location匹配规则
- nginx配置中location的语法
- nginx配置中location的匹配规则
- Nginx中 location 在配置中的优先级
- Nginx location
- nginx Location
- nginx location
- nginx location
- location nginx
- nginx location
- nginx 中nginx.config 的location配置详解
- nginx中location中关于proxy_pass和rewrite的应用
- 实例区分nginx location中rewrite的break与last
- nginx中location的root和alias用法区别
- nginx中文翻译: location 指令
- Nexus Maven Repository
- 使用Python快速建立FTP服务器
- ES错误Error:Failed to parse mapping [data]:[_ttl] is removed in 5.0
- Chapter 2 Computer Evolution And Performance
- 11.PHP.ini配置文件中文(3)
- Nginx中location
- 什么是机器学习?
- Windows8.1首次安装Pycharm出现No Python interpreter selected解决方法
- Chapter 3 A top-level view of computer function and interconnection
- PHP基础2
- Java中Timer的用法
- 如何求卡方分布的P值
- shift
- disruptor 简介《转载》