如何编写 nginx 重写规则以捕获相对路径中的 /static

How to write nginx rewrite rule to catch /static in relative path

我想重写以下网址。 static之前可以有好几条路径。所以我想删除所有这些并只获取以 /static

开头的 url
*/static/js/52.eebbab07.chunk.j
someurl/subpath1/subpath2/static/js/52.eebbab07.chunk.j

至此

/static/js/52.eebbab07.chunk.j

我该怎么做?

怎么样:

rewrite /static/(.*)$ /static/ last;

rewrite 指令允许在 /static 之后捕获 URI 的尾部部分,替换(第二个参数)可以将其用作 .