How to avoid docx and xlsx turning into zip when downloaded


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/ .docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/ potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/ ppam
AddType application/ ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/ pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/ xlam
AddType application/ xlsb
AddType application/ xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/ 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.

  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