0

In nginx, how can we rewrite:

http://example.com/wp-content/uploads/2012/08/mysong.mp3

to:

http://mp3.example.com/2012/mysong.mp3

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • 1
    possible duplicate of [How to write a url rewrite in nginx?](http://stackoverflow.com/questions/4329316/how-to-write-a-url-rewrite-in-nginx) – shantanoo May 26 '15 at 09:16
  • honestly, can't se how it's duplicated since the post you mention only deals with one var ($1) and in this case, beyond the year ($1) we need also to capture the filename ($2) – Guigo2k May 26 '15 at 19:34
  • also, it must rewrite only URIs ending with .mp3 and NOT any other extension line .png or .jpg for example. thanks! – Guigo2k May 26 '15 at 19:44
  • You need to write `rewrite` rule to check for `$2`. You may like to check http://nginx.org/en/docs/http/ngx_http_rewrite_module.html – shantanoo May 27 '15 at 06:59

0 Answers0