IE7 And Apache File Type Gotcha

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.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.