Forcing file downloads with Apache, mod_rewrite, and mod_headers
The Problem: A link to a QuickTime file normally results in the Quicktime plugin opening the file within the browser, which is unhelpful for the user who wants to download the file.
The Solution: While a right-click ‚"Save As" is intuitive for the technical user, it makes life difficult for some.The easy solution is to send a Content-Disposition header using an .htaccess file:
This is fine, except it will always try to force the user to download the file, which might not be desirable. The solution to this is to use mod_rewrite and environmental variables to conditionally force the download:
In ./download/.htaccess
In ./.htaccess
Now, when a user browses to http://example.org/movie.mp4, the QuickTime plugin will perform its default action, and when the user goes to http://example.org/download/movie.mp4, they will be prompted to download the file.