How to Force file downloads when using file download elements on your site with OptimizePress.

For Files Hosted in your media library or on your server:

Have you ever tried linking to a "pdf" or "mp3" file in the files download element but then when you click on it it loads in the browser instead of downloading?

Here is a fix for this. You can add this to the bottom of your .htaccess file for your site (please note that you should take a backup of your .htaccess file before editing).

<FilesMatch "\.(?i:mp3)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

Note: You can change "pdf" or "mp3" to other file extensions but do not use .php, .js, .css, or any other file extension used in the coding of your sites or you may break the ability for your site to function.

Note: If using the "Membership Files Download" Element in the live editor, OptimizeMember automatically handles this for you for most files, however if using the regular (non members) "Files Download" element, you may need to use this method above to force the downloads.

 

For Files Hosted on Amazon S3:

To force the download of files on Amazon S3, you'll need to login to your Amazon S3 console at http://aws.amazon.com and navigate to the files you wish to modify. Then follow these steps:

  1. Right click on the file you wish to set this up for and go to "properties"
  2. Click on "Metadata"
  3. Click on "Add More Metadata"
  4. For "Key" select "Content-Disposition"
  5. For "Value" select "Attachment"
  6. Click the blue "save" button in the bottom right corner.

You can do this for any number of files on your Amazon S3 account and this will force that file to download rather than loading in your browser. Note that zip files don't need this as those typically download automatically anyways.