开发者

NGINX rewrite for static dir

开发者 https://www.devze.com 2023-01-03 01:20 出处:网络
I\'m trying to translate: mydomain.com/98387634/image/file.png to: mydomain.com/image/file.png Can anyone tell me wh开发者_高级运维at\'s wrong with my rewrite?

I'm trying to translate:

mydomain.com/98387634/image/file.png

to:

mydomain.com/image/file.png

Can anyone tell me wh开发者_高级运维at's wrong with my rewrite?

rewrite ^~/static/(.*)/(.*)$ ~/static/$2 last;

location ^~/static {
        expires max;
        root /var/www;
}


By default, *' AND+' in regular expressions are greedy. You must use `.*?' or write rewrite something like this:

rewrite ^~/static/[^/]*/(.*)$ ~/static/$1 last;
0

精彩评论

暂无评论...
验证码 换一张
取 消