-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
  • 712
  • 1
  • 9
  • 30

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
  • 6,133
  • 2
  • 20
  • 25