Apache 2: raising a file download dialog box for certain static files
Many browsers (including Firefox and Internet Explorer) have plugins for several file types installed so they can show the files’ content inline. This is useful for things like Flash videos, may be useful for other videos and audio files, is sometimes annoying for PDF files and certainly unwanted for binary files etc.
There’s a HTTP header that instructs browsers to show a dialog box instead of showing the files inline. It’s called Content-Disposition: attachment and is defined in RFC 2183.
If you want to make all files in a directory available for download (and not for viewing inline), you can simply put this .htacess file into the directory:
RewriteRule (.*)$ - [E=DOWNLOAD:$1]
Header onsuccess set Content-Disposition "attachment; filename=%{DOWNLOAD}e" env=DOWNLOAD
You need mod_headers and mod_rewrite enabled and all other requirements for RewriteRules in .htaccess files, i.e. Options FollowSymlinks / SymLinksIfOwnerMatch and correct AllowOverride settings.