nginx location语法
location [=|~|~*|^~] /uri/ { … }
说明:
= 严格匹配。如果请求匹配这个location,那么将停止搜索并立即处理此请求
~ 区分大小写匹配(可用正则表达式)
~* 不区分大小写匹配(可用正则表达式)
!~ 区分大小写不匹配
!~* 不区分大小写不匹配
^~ 如果把这个前缀用于一个常规字符串,那么告诉nginx 如果路径匹配那么不测试正则表达式
举例说明
#示例1:
#匹配任意请求
location / { }
#示例2:
#不区分大小写匹配任何以gif、jpg、jpeg结尾的请求,并将该请求重定向到 /logo.png请求
location ~* .(gif|jpg|jpeg)$ {
rewrite .(gif|jpg|jpeg)$ /logo.png;
}
#示例3:
#区分大小写匹配以.txt结尾的请求,并设置此location的路径是/usr/local/nginx/html/。
#也就是以.txt结尾的请求将访问/usr/local/nginx/html/ 路径下的txt文件
location ~ ^.+\.txt$ {
root /usr/local/nginx/html/;
}
alias与root的区别
- root 实际访问文件路径会拼接URL中的路径
- alias 实际访问文件路径不会拼接URL中的路径
#示例4:
location ^~ /sta/ {
alias /usr/local/nginx/html/static/;
}
#说明:
#请求:http://test.com/sta/sta1.html
#实际访问:/usr/local/nginx/html/static/sta1.html 文件
#示例5:
location ^~ /tea/ {
root /usr/local/nginx/html/;
}
#请求:http://test.com/tea/tea1.html
#实际访问:/usr/local/nginx/html/tea/tea1.html 文件
版权声明:除特别注明外,本站所有文章均为王晨曦个人站点原创
转载请注明:出处来自王晨曦个人站点 » Nginx的location匹配规则
High-Quality Mictrostrip Circulator Company Factories yellow-sheep-d640e0f7a04ff5f8.znlc.jp High-Quality Mictrostrip Isolator Pricelist Products China Microwave Isolator Product Factories China Microwave Circulator Design Exporter High-Quality Radio Circulator Supplier Factories
www.client.gaucbc.org Best Mobile Energy Supply Factories ODM Solar Panel Power Bank Service OEM Camping Battery Bank Factories Products Best Mobile Energy Storage Products Best Camping Battery Bank Suppliers Factory
nextplanner.jp 赌厅网投 贝博足彩 澳门博狗 赌厅网投 贝博足彩
在线赌场游戏 赌厅网投 在线赌场游戏 贝博足彩 news.gaucbc.org 在线赌场游戏
www.jslcd.co.kr 赌厅网投 贝博足彩 在线赌场游戏 贝博足彩 赌厅网投
carboman.eu 澳门博狗 贝博足彩 在线赌场游戏 贝博足彩 赌厅网投
贝博足彩 赌厅网投 dashboard.megedcare.com 赌厅网投 澳门博狗 澳门博狗
www.klickstreet.com 澳门博狗 贝博足彩 在线赌场游戏 贝博足彩 贝博足彩
help.gaucbc.org 在线赌场游戏 澳门博狗 赌厅网投 澳门博狗 在线赌场游戏
贝博足彩 赌厅网投 store.megedcare.com 澳门博狗 贝博足彩 赌厅网投
在线赌场游戏 贝博足彩 贝博足彩 澳门博狗 澳门博狗 www.girobots.ru
www.nextplanner.jp 赌厅网投 赌厅网投 在线赌场游戏 贝博足彩 澳门博狗
赌厅网投 www.tupelo.pl 赌厅网投 在线赌场游戏 澳门博狗 澳门博狗
在线赌场游戏 在线赌场游戏 jslcd.web-bi.net 在线赌场游戏 赌厅网投 澳门博狗
kotki.eu
jslcd.co.kr