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/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.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.



You rock !
It solved my problem ! Thanks a lot !