Force Files to Download Instead of Opening
Have ever wished that you could force a file to download instead of opening in a browser? Some common files like MP3s and PDFs will open in your reader’s browser if the proper parent plugin is installed. Sometimes you want to force them to download the file without having to right-click and save it.
This action can be achieved very easily in Apache by modifying the .htaccess file. You can set it at your domain root to affect your entire site, or you can set it in subdirectories to only affect parts of your site.
All you need to know is your file extension(s). Then add an octet-stream mime type for each. So you might add the following to your .htaccess file.
AddType application/octet-stream .avi AddType application/octet-stream .mpg AddType application/octet-stream .mov AddType application/octet-stream .pdf
The above example would force a download message and prevent any AVI, MPG, MOV, or PDF file from opening in a browser.
Please use the trackback link when linking to this post.

































August 25th, 2008 at 10:57 am
Hey,
Thanks for the tip! I have been trying to get this result for a few hours now. I have set up HTML email signatures for everyone in my office with a link to download our Vcards, but the vcfs keft displaying in the browser. Thank you very much!
August 25th, 2008 at 1:08 pm
No problem at all. I’m glad you found this tip helpful!
October 27th, 2008 at 7:36 am
I need running this at IE6 , but not working.
not force download in ie6.
att,
Cristiano