{"id":4608,"date":"2018-08-17T18:51:53","date_gmt":"2018-08-17T18:51:53","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2018\/08\/17\/how-to-force-file-downloads-with-the-htaccess-file\/"},"modified":"2023-11-27T15:49:41","modified_gmt":"2023-11-27T20:49:41","slug":"how-to-force-file-downloads-with-the-htaccess-file","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/","title":{"rendered":"How to Force File Downloads with the Htaccess File"},"content":{"rendered":"<p>When you use an Htaccess file, you&#8217;re basically giving special instructions to the Apache web server itself. This is especially important in our <a href=\"\/shared-hosting\">shared server hosting<\/a>\u00a0packages, 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.<\/p>\n<h2 id=\"why-force-file-downloads\">Why Force File Downloads<\/h2>\n<p>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.<\/p>\n<h2 id=\"force-file-downloads-htaccess\">How to Force File Downloads with the Htaccess File<\/h2>\n<p>First, you will need to make sure that you edit the right file. Usually, the <code>.htaccess<\/code> 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&#8217;s home directory meant to recursively affect directories beneath it.<\/p>\n<p class=\"alert alert-info\">If you have a WordPress site, your Htaccess file be installed in the same directory as all of the other WordPress core files.<\/p>\n<p>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 <a href=\"\/support\/edu\/cpanel\/using-file-manager-in-cpanel\/\">cPanel file manager<\/a>.<\/p>\n<p>Once you&#8217;ve opened the Htaccess file for editing, add these snippet of code, adding any file extensions you require:<\/p>\n<pre class=\"example\"> AddType application\/octet-stream .avi .mpg .mov .pdf .xls .mp4<\/pre>\n<p><small>Source: <a href=\"https:\/\/codex.wordpress.org\/htaccess\">WordPress.org<\/a><\/small><\/p>\n<h2 id=\"tips-and-tricks\">Htaccess Tips and Tricks<\/h2>\n<p>As mentioned above, making best use of the Htaccess files is especially important in our Business Class hosting accounts. There&#8217;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.<\/p>\n<p>We&#8217;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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you use an Htaccess file, you&#8217;re basically giving special instructions to the Apache web server itself. This is especially important in our shared server hosting\u00a0packages, 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.<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-4608","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Force File Downloads with the Htaccess File | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article, we&#039;ll show you how you can force file downloads from your website using the Htaccess file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Force File Downloads with the Htaccess File | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article, we&#039;ll show you how you can force file downloads from your website using the Htaccess file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-17T18:51:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-27T20:49:41+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"How to Force File Downloads with the Htaccess File\",\"datePublished\":\"2018-08-17T18:51:53+00:00\",\"dateModified\":\"2023-11-27T20:49:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\"},\"wordCount\":361,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\",\"name\":\"How to Force File Downloads with the Htaccess File | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2018-08-17T18:51:53+00:00\",\"dateModified\":\"2023-11-27T20:49:41+00:00\",\"description\":\"In this article, we'll show you how you can force file downloads from your website using the Htaccess file.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Force File Downloads with the Htaccess File\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Force File Downloads with the Htaccess File | InMotion Hosting","description":"In this article, we'll show you how you can force file downloads from your website using the Htaccess file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/","og_locale":"en_US","og_type":"article","og_title":"How to Force File Downloads with the Htaccess File | InMotion Hosting","og_description":"In this article, we'll show you how you can force file downloads from your website using the Htaccess file.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2018-08-17T18:51:53+00:00","article_modified_time":"2023-11-27T20:49:41+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"How to Force File Downloads with the Htaccess File","datePublished":"2018-08-17T18:51:53+00:00","dateModified":"2023-11-27T20:49:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/"},"wordCount":361,"commentCount":7,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/","name":"How to Force File Downloads with the Htaccess File | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2018-08-17T18:51:53+00:00","dateModified":"2023-11-27T20:49:41+00:00","description":"In this article, we'll show you how you can force file downloads from your website using the Htaccess file.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-force-file-downloads-with-the-htaccess-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Force File Downloads with the Htaccess File"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4288,"name":"Website","slug":"website","link":"https:\/\/www.inmotionhosting.com\/support\/website\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=4608"}],"version-history":[{"count":2,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4608\/revisions"}],"predecessor-version":[{"id":108009,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4608\/revisions\/108009"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=4608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=4608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=4608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}