How to Force File Downloads with the Htaccess File InMotion Hosting ContributorUpdated on November 27, 2023 2 Minute Read When you use an Htaccess file, you’re basically giving special instructions to the Apache web server itself. This is especially important in our shared server 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 Source: WordPress.org 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. Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles Intro to Migrating your WordPress Site Data Migrating your WordPress Database Migrating WordPress Files Configuring WordPress After a Migration Testing your WordPress website after Migration How to Move WordPress from a Subfolder to the Root Directory What to expect during a mass server migration Move Your WordPress Site to a New Server Moving Websites Built with Older Technology into WordPress How to Export Your WordPress Sites