So that /media/file.jpg
opens in browser and /media/file.jpg?dl=1
forces browser to download.
Here's my current config, that doesn't work:
location /media/ {
autoindex off;
root /home/my_app/media/;
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 365d;
add_header Pragma public;
add_header Cache-Control "public";
}
# Allow forcing download by query param `dl`
if ($arg_dl = "1") { # why this doesn't work?
add_header Content-disposition "attachment; filename=$1";
}
}