NGINX rewrite syntax inside location block
Solution 1:
From the start of the request. There is documentation on that here.
location /download/ {
rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break;
rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break;
return 403;
}
Solution 2:
The documentation implies that the full URL is matched (i.e. your first example).