.htaccess download pdf

Hi,

I have a site with 2 pdf-forms. I'd like to force the browser to download them instead of opening in the browser window.

Site runs on apache with nginx proxy.

In the folder containing the 2 files I have this .htaccess:

 <files *.pdf="">ForceType applicaton/octet-stream
  Header set Content-Disposition attachment</files> 

the nginx virtualhostfile has

l ocation ~* ^.+\.(htm|html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|bz2|pdf|odt|txt|tar|bmp|rtf|js|swf|avi|mp4|mp3|ogg|flv) (\?.*)?$ { expires 30d; #adjust to your static content's update frequency root /sites/public_html; } location ~ /\.ht { deny all; } }

However, the browser keeps on opening the file instead of downloading it

3 Replies

Zip'm, then the browser doesn't have a choice but to save to disk.

I know, but unzipping them is an extra step before they can be filled in , which is not user-friendly

Not sure if you were able to solve this or not, but this has worked for me in the past:

~~[http://www.nakedmcse.com/Home/tabid/39/forumid/14/postid/42/scope/posts/Default.aspx" target="_blank">](http://www.nakedmcse.com/Home/tabid/39/ … fault.aspx">http://www.nakedmcse.com/Home/tabid/39/forumid/14/postid/42/scope/posts/Default.aspx](

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct