Admin

Forcing downloads with htaccess

Downloading a document from a website may not always be that straightforward for some users.  

After users click a link that points to, say, a Microsoft Word document, the browser may actually try to display that document instead of downloading it (or it may try to download it as a ZIP archive). This may result in a blank page or an error message.

Browsers could have this behavior with any of the following file types:

  • doc/docx
  • xls/xlsx
  • ppt/pptx
  • odf
  • pdf
  • rtf
  • ics (calendar files)
  • psd, ai, fla, or other application-native file types

To help prevent this issue, you can force the browser to download certain files with an htaccess rule, to make sure it will not try to render them or download them as another type.

<FilesMatch ".(?i:doc|docx|xls|xlsx|ppt|pptx|odf|pdf|rtf|txt|ics)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

To edit htaccess, go to Admin > Site > htaccess. Please edit with caution; any incorrect htaccess rule may break the site until it is corrected. If you are not comfortable editing htaccess, contact Support.

When a web browser downloads a file, it will place it in the specified "downloads folder" on your computer (which can be set in the browser's preferences).


Article Rating
Was this article helpful?*

Additional Article Feedback

See more in Admin →