{"id":702,"date":"2023-02-14T10:33:50","date_gmt":"2023-02-14T10:33:50","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2023\/02\/14\/6987484-how-to-make-files-downloadable-upon-a-click-on-a-link\/"},"modified":"2026-08-10T06:25:05","modified_gmt":"2026-08-10T06:25:05","slug":"6987484-how-to-make-files-downloadable-upon-a-click-on-a-link","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/6987484-how-to-make-files-downloadable-upon-a-click-on-a-link\/","title":{"rendered":"How to make files downloadable upon a click on a link"},"content":{"rendered":"<p>Make files downloadable upon a click on a link, forcing a download instead of the default browser preview behavior. Normally, clicking a file URL opens it in the browser &mdash; you can force it to download instead using the .htaccess file.<\/p><h3>Before you start<\/h3><ul>\n<li>If you don&rsquo;t have an .htaccess file yet, see <a href=\"https:\/\/www.hostinger.com\/support\/1583307-how-to-create-an-htaccess-file-at-hostinger\/\">how to create an .htaccess file at Hostinger.<\/a><\/li>\n<\/ul><h2 id=\"h-force-file-downloads\">Force file downloads<\/h2><p class=\"no-margin\">Access the <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/4548688-basic-actions-in-the-file-manager-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">File Manager<\/a><\/b>, find the <b>.htaccess<\/b> file, and open it to edit. Add the snippet of code below, <b>specifying all the preferred file extensions <\/b>that you want to make downloadable upon a click on the link:<\/p><pre><code>&lt;FilesMatch \"\\.(avi|mpg|mov|pdf|xls|mp4)$\"&gt;\r\n    ForceType application\/octet-stream\r\n    Header set Content-Disposition attachment\r\n&lt;\/FilesMatch&gt;<\/code><\/pre><p class=\"no-margin\">For example, if you&rsquo;d like to make only the .pdf files downloadable, the line of code would look like this:<\/p><pre><code>&lt;FilesMatch \"\\.pdf$\"&gt;\r\n    ForceType application\/octet-stream\r\n    Header set Content-Disposition attachment\r\n&lt;\/FilesMatch&gt;<\/code><\/pre><p class=\"no-margin\">Save the changes, and that&rsquo;s it! If you can&rsquo;t see the changes on your live website, try <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/1583501-how-to-clear-cache-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">clearing the cache<\/a><\/b>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to force file downloads using the .htaccess file<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[237],"tags":[],"class_list":["post-702","post","type-post","status-publish","format-standard","hentry","category-htaccess-file"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/6987484-how-to-make-files-downloadable-upon-a-click-on-a-link\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/6987484-como-hacer-que-los-archivos-se-descarguen-al-hacer-clic-en-un-enlace-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/6987484-comment-rendre-les-fichiers-telechargeables-en-un-clic-sur-un-lien\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/6987484-cara-membuat-file-dapat-diunduh-setelah-mengklik-tautan-di-hostinger\/","default":0},{"locale":"lt-LT","link":"https:\/\/www.hostinger.com\/lt\/support\/6987484-kaip-padaryti-kad-spustelejus-nuoroda-automatiskai-butu-atsiunciamas-failas-hostinger\/","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/support\/6987484-como-tornar-os-arquivos-disponiveis-para-download-com-um-clique-em-um-link-no-hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":2,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"predecessor-version":[{"id":14980,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/702\/revisions\/14980"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}