I have this mp3 url:
http://example.com/downloads/low_quality/songs/song_name.mp3
and i want force rewrite to this url without allow downloading first url:
http://example.com/downloads/high_quality/songs/song_name.mp3
Indeed i need replace low_quality
with high_quality
path. I trying use alias
and rewrite
, but not working. it start downloading first url low_quality
.
location /downloads/low_quality/ {
alias /downloads/high_quality/;
}
or
location ~* ^/downloads/low_quality/(.*)$ {
rewrite ^/downloads/low_quality/(.*)$ http://example.com/downloads/high_quality/$1 permanent;
break;
}
// but low quality download started!
low_quality
file always is exists but i don't want downloading when requested. i want redirect(rewrite) to second url high_quality
.
CodePudding user response:
according to https://www.nginx.com/blog/creating-nginx-rewrite-rules/
this is true rewrite:
rewrite ^/downloads/low_quality/songs/(\w )\.?.*$ /downloads/high_quality/songs/$1.mp3 last;
high quality requested and downloaded.