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/ .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


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.