How to Force File Downloads with the Htaccess File

When you use an Htaccess file, you’re basically giving special instructions to the Apache web server itself. This is especially important in our Business Class hosting packages, where the user does not have access to the Apache configuration files. You can pass many of the same directives through the Htaccess file itself without requiring root access.

Why Force File Downloads

By default, when users visit your page and click on a PDF or an audio file, it will be open up in the web browser itself. This works for most cases, but if your goal is to have your users actually download the file, you can make it easier for them by forcing the download as soon as they click the link.

How to Force File Downloads with the Htaccess File

First, you will need to make sure that you edit the right file. Usually, the .htaccess file will be located in the document root of the site it is affecting. However, sometimes an Htaccess file will be placed in the cPanel user’s home directory meant to recursively affect directories beneath it.

If you have a WordPress site, your Htaccess file be installed in the same directory as all of the other WordPress core files.

In order to proceed, you will need a sensible way to edit files. For adding Htaccess directives, the easiest way to get to the file will be through the cPanel file manager.

Once you’ve opened the Htaccess file for editing, add these snippet of code, adding any file extensions you require:

 AddType application/octet-stream .avi .mpg .mov .pdf .xls .mp4 


Htaccess Tips and Tricks

As mentioned above, making best use of the Htaccess files is especially important in our Business Class hosting accounts. There’s a lot you can do without requiring the elevated responsibilities of root user access. The Htaccess file is a bridge between the default cPanel user account and the deeper levels of the Apache configuration.

We’d love to hear any tips or tricks you may have for neat things you can do with the Htaccess file. Be sure to leave them in the comment section below.

Thoughts on “How to Force File Downloads with the Htaccess File

    • I’m sorry to see you are facing a problem. Can you please provide any error or which step in the process outlined in this article you are experiencing issues with? This will help us to assist you in finding a resolution. If you are a customer of InMotion Hosting, you can always contact our Live Technical Support for more personal assistance with your account.

Leave a Reply