3

My website is at /root/website/, in it there is a folder static for static files, when the user visit: /static/dfd99a5/xxx.js, I wish to serve /root/website/static/xxx.js, how can I do this in nginx?

cnst
  • 25,870
  • 6
  • 90
  • 122
wong2
  • 34,358
  • 48
  • 134
  • 179
  • You could define a new location block and redirect from there. It would be best to post your config as well. – Keenan Lawrence Jul 03 '16 at 17:50
  • @wong2, has your question been resolved? if yes, please accept&&upvote, if no, please clarify what's missing. – cnst Jul 11 '16 at 17:12
  • @wong2, thanks for accept! is there something still missing from my solution or incomplete in any way? if yes, let me know what is it. if no, why was it not upvoted? thanks. – cnst Jul 12 '16 at 06:38

1 Answers1

2

You can use the rewrite directive like so:

location ~ ^(/static)/[0-9a-f]+(/.+)$ {
    rewrite ^ $1$2 break;
}
cnst
  • 25,870
  • 6
  • 90
  • 122