php 正则匹配静态资源,Nginx配置静态资源

laction

Syntax: location [ = | ~ | ~* | ^~ ] uri { ... }

location @name { ... }

Default: —

Context: server, location

location 有两种匹配路径的方式:前缀字符串匹配(prefix string)和正则表达式匹配(regular expression)

默认会优先前缀字符串匹配,再进行正则表达式匹配

若 正则表达式匹配成功 则使用其匹配结果

否则 使用前缀字符串匹配的结果

此时 前缀字符串匹配也失败的话 就会报错

符号的使用:

~* 对大小写不敏感

~ 对大小写敏感

= / 精确匹配 (用于常用的路径匹配,能增加匹配速度)

^~ 不匹配正则表达式

ex:

```

location = / {

[ configuration A ]

}

location / {

[ configuration B ]

}

location /documents/ {

[ configuration C ]

}

location ^~ /images/ {

[ configuration D ]

}

location ~* .(gif|jpg|jpeg)$ {

[ configuration E ]

}

```

“/” match configuration A

“/index.html” match configuration B

“/documents/document.html” match configuration C

“/images/1.gif” match configuration D

/documents/1.jpg match configuration E

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值