Force download of files

Hi

I am trying to force the download of pdf files from my server, rather than open them in the browser.

I have unsuccessfully tried

location ~* /wp-content/(.+.pdf)$ { internal; add_header Content-disposition “attachment; filename=$1”; }

Any suggestions?

@robbie_berns

try something like this

server { listen 80; server_name example.com; location ~ ^.*/(?P<request_basename>[^/]+\.(pdf))$ { root /path/to/pdf/folder/ add_header Content-Disposition 'attachment; filename="$request_basename"'; } } let me know if that works for you.