How to avoid docx and xlsx turning into zip when downloaded

Total
0
Shares

I run yesterday in a very interesting problem. On one website the client had some downloadable files in docx and xlsx format. But when downloaded with Internet Explorer the files were downloaded as zip files instead of docx or xlsx. If you renamed the downloaded zip file into xlsx or docx they worked but this is a workaround and not a solution for the client.

So i identified the problem quickly and the problem was with the Apache server not being able to identify MIME Types correctly for these files.  I found two solutions:

1) add this to your .htaccess file:

AddType application/vnd.ms-word.document.macroEnabled.12 .docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx

2) find the file /etc/mime.types on your server and add the code above to that file

You may need to restart your Apache server to activate these changes. After this you can download docx or xlsx files in their original format and with the name unchanged.

6 comments
  1. It doesn’t fix the problem for me.
    Some of the docx and xlsx files continue to download as zip files.

  2. Worked prefectly for Office 2010 documents, key was to put your apllications lines in the conf\mime.types file and restart Apache.
    Also clear out the cache and then check the page with link after a Ctrl+F5 page refresh.

    Thank you, you saved me a lot of time!

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like