-2

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?

Pubudu Jayasanka
  • 1,294
  • 4
  • 18
  • 34

1 Answers1

1

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.

Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35