# Why are docx, xlsx, pptx downloading from webserver as zip files?

On my Apache server I have stored several docx, xlsx pptx files.

Some client browsers think that theses are regular zip files and change the file extension when downloading. How do I make it not do that anymore.

(Using Ubuntu server)

-
These file types work fine with IE9 without making any changes to the htaccess, httpd.conf, etc. –  user107566 Jan 19 '12 at 14:17

## 5 Answers

The files are actually ZIPs of XML documents. Add this to your .htaccess in Apache

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

-
there's a typo in the first line. It should just be docm with no . –  daveilers Jun 3 '09 at 19:07
Fixed. Thanks. –  Kevin Kuphal Jun 3 '09 at 19:16
I had the same problem and added this to .htaccess, but the same thing still happens in IE (even after deleting cache). Do you have to restart Apache for this to take effect? –  supertrue Oct 3 '11 at 19:33

The server doesn't have proper mime types set up for the new ms file types

add the following to the /etc/mime.types file and restart apache and the problem should be fixed.

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


http://www.webdeveloper.com/forum/showthread.php?t=162526 has information about this problem

-
since this is my server and I have access to /etc/mime.types this is the best answer for me. –  daveilers Jun 3 '09 at 19:11
on windows, the path may be something like <install dir for apache>\apache\conf\mime.types –  AJ. Jul 2 '14 at 15:03

Sounds like your web server is looking at the magic numbers inside these files and seeing that they ARE zip files.

Have a look at: http://www.webdeveloper.com/forum/showthread.php?t=162526

-

I have total administrative control of both the server and the client machine involved with this problem and NONE of these proposed solutions worked for correcting this problem.

In the end, the only thing that FIXED this issue for me was to....

1) uninstall 7-Zip (so the browser has nothing to associate with the zip file)

2) (Not sure if this step is required, but) I then downloaded the DOCX again, (where, coincidentaly, it's still being presented as a ZIP file), however, this time I am prompted for what application to open it with and I choose MSWORD. I don't choose "Always open with MSWORD", because I don't want MSWORD always opening ZIP files.

3) Re-install 7-Zip.

After this, all subsequent attempts to download the DOCX, actually resulted in a DOCX file being download and opened with the appropriate MSWORD application.

NOTE: Before you jump to the conclusion that I simply had a broken file association, let me confirm, that when this problem was occurring, I could double-click on any DOCX in explorer and MSWORD would always open it. This problem was always and only occurring when trying to download/open a DOCX with IE8. FF4 and Chrome both worked flawlessly. I tried adding the proper MIME types to /etc/mime-types and to .htaccess on the server side. I also tried Disabling "Open files based on content, not file extension" (but this only resulted in the browser open the DOCX as unreadable ASCII text), setting the FEATURE_MIME_* registry keys to "0", and adding the server URL to the "Trusted Sites" list. Again, NONE OF THESE SEEMINGLY LOGICAL SOLUTIONS WORKED FOR ME.

I hope this is helpful to someone. Cheers!

Ken Banks

-
it's quite possible for the association on your desktop for local .docx files to be correct while still not matching application/vnd.openxmlformats-officedocument.wordprocessingml.document files from a web server. Check the registry value HKCR\.docx\ContentType –  James Jul 16 '13 at 4:22

Download http://packages.ubuntu.com/oneiric/mime-support, and install it with dpkg -i. Worked great!

PS: Apache on Ubuntu and Debian reads from /etc/mime.types

-