nginx正则匹配

2019-12-18  本文已影响0人  钱英俊真英俊

需求:由于运营商缓存,需要域名后加上时间以便绕过缓存,例:www.name.com/yyyy-mm-dd/www.name.com返回同样的数据,这时候就需要nginx的正则匹配

写法
location ~ ^/\d+\-\d+\-\d+/(.*)$ {
      alias /etc/nginx/html/$1;
}

If alias is used inside a location defined with a regular expression then such regular expression should contain captures and alias should refer to these captures (0.7.40), for example:

location ~ ^/users/(.+\.(?:gif|jpe?g|png))$ {
    alias /data/w3/images/$1;
}
上一篇 下一篇

猜你喜欢

热点阅读