Mar

19

Sometimes you want files in certain format like PDF to be downloaded instead of opened in new browsers. Because such files normally have very large size and may cause your browser run out of memory. With Apache .htaccess, file force download can’t be easier. See the example below:


<FilesMatch "\.(pdf|mp3)$">
ForceType application/octet-stream
</FilesMatch>


This example will download all pdf and mp3 files when directly linking to them. If you view them in a web page, they will display, but if linked directly to them they will show you the save box. (Files don’t seem to download if they are saved in cache Ctrl+F5 to fix that).



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. Roy van Wensen on November 28, 2008 7:51 am

    this is not working want to use this.

    ForceType application/pdf
    Header set Content-Disposition attachment

Sponsors




Links