I want to rewrite following URLs. There can be several paths before static. So I want to remove all of them and just get the url starting with /static
*/static/js/52.eebbab07.chunk.j
someurl/subpath1/subpath2/static/js/52.eebbab07.chunk.j
to this
/static/js/52.eebbab07.chunk.j
How can I do that?
How about:
rewrite /static/(.*)$ /static/$1 last;
The rewrite
directive allows to capture trailing part of URI after /static
, and the substitution (second argument) can use it as $1
.