How to force your website to download a file (rather than opening)

07/05/2013

I wanted to add a download link to one of my products. The file was an Windows Installer Package (*.msi).

However, FireFox started to open the file on the browser rather than downloading it so when my visitors tried to download the installer they would rather see some gibberish on the browser because FireFox was trying to “open” the MSI file.

There’s a simple fix.

Just add following line to your .htaccess file so that your website will force your browser to download this type of files than trying to open them.

# force download
AddType application/octet-stream .msi

You can use this method for any type of files. Just add another copy of this line and change the last three characters to your preferred file extension.

e.g. Following code will force browsers to download any *.jpg, *.bat, or *.config files as well

# force download
AddType application/octet-stream .msi
AddType application/octet-stream .jpg
AddType application/octet-stream .bat
AddType application/octet-stream .config

Menol

ILT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: