IE7 And Apache File Type Gotcha

Microsoft Office .docx file extension read by Internet Explorer 7/8 as a Zip file

Photo of Greg Harvey
Fri, 2009-05-08 15:48By greg

Firstly, thanks for Russ at Manta Ray Media for doing the Google leg-work on this one.

Apparently the new(ish) Microsoft Office .docx file extension (in fact, all the new .foox file extensions) is read by Internet Explorer 7/8 as a Zip file when being served by an Apache web server. This is because the sent headers from Apache are incomplete and IE gets confused and thinks it is receiving a zipped archive, not an Office document. (Isn't it wonderful that only Microsoft's browser gets confused by Microsoft's file formats!)

What to do? Tell Apache about these new fandangled MS formats so it can serve them correctly. Russ added these lines to his .htaccess file and it worked:

# Amend MIME types to enable files to open correctly in IE7+

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

Of course, a Drupal developer would never change the core .htaccess file unless they had no option. So put these in http.conf if you can, not in .htaccess. Otherwise you'll have to be super careful when updating your Drupal core or you'll break it again by over-writing the altered .htaccess file.