Serving Office 2007 Docx Filetypes from an Apache Server

by Jonathan on September 1, 2010

tim berners-lee's first webserver

I recently worked on a project for my employer, Insource Technology, to develop a corporate blog. As the project progressed we ran into an interesting problem. An author would upload a .docx file to the site without an issue. When the file was downloaded it would not download as a .docx file but as a .zip file. When the .zip file was extracted the contents showed the XML structure of the .docx file but the file was not readable by Microsoft Word.

Background

Microsoft’s XML Document Format

With the release of Office 2007, Microsoft released a new file format based on XML. Microsoft dubbed this new file format Open XML and claimed many tangible advantages including smaller file size, improved privacy control and better integration. A full list of extensions and more in-depth information on the Open XML format can be found here

MIME File Types

Multipurpose Internet Mail Extensions (MIME) is an internet standard designed to identify the type of media content served by a web browser. The MIME types are used to help web browsers understand how to handle file types presented by a web browser or email application. Some of these MIME file types are set up by default to be interpreted correctly by the server. On some servers the .docx filetype is not set up by default.

Solution

Serving Office 2007 documents from an Apache Web Server

If you are running a blog on an apache web server you will need to add the following code to a .htaccess file in the root directory of your blog site. If you already have a .htaccess file you can add this to that file. No restart of the apache server is required.

application/vnd.openxmlformats-officedocument.wordprocessingml.document docx application/vnd.ms-word.document.macroEnabled.12 docm application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx application/vnd.ms-word.template.macroEnabled.12 dotm application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx application/vnd.ms-excel.sheet.macroEnabled.12 xlsm application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx application/vnd.ms-excel.template.macroEnabled.12 xltm application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb application/vnd.ms-excel.addin.macroEnabled.12 xlam application/vnd.openxmlformats-officedocument.presentationml.presentation pptx application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm application/vnd.openxmlformats-officedocument.presentationml.template potx application/vnd.ms-powerpoint.template.macroEnabled.12 potm application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam application/vnd.openxmlformats-officedocument.presentationml.slide sldx application/vnd.ms-powerpoint.slide.macroEnabled.12 sldm application/vnd.ms-officetheme thmx application/onenote onetoc application/onenote onetoc2 application/onenote onetmp application/onenote onepkg

Serving Office 2007 document from and IIS Web Server

It is not necessary to add the MIME file types to versions of IIS 7.0 or greater. Microsoft’s Technet has a full article outlining the process to Register the 2007 Office system file format MIME types on servers. This article includes how to add the MIME file types to IIS 6.x web servers.

  • Mikejensen

    Hi Jonathan, Is the Houston Area SQL Server Group still around? Just curious if they are around and still meetup or not? Thanks.

  • http://www.jonathanagardner.com Jonathan Gardner

    The HASSUG is still around and will meet tomorrow, Tuesday Sept 14th. Here are some more details.

    Houston Area SQL Server User Group Monthly Meeting Reminder

    When: Tuesday, September 14, 2010 – 11:30am-1:00pm Where: Microsoft Houston Office 2000 W. Sam Houston Pkwy. S. #350 Houston, Texas 77042-3615

  • http://www.astwoodconsulting.co.uk/ ms excel training

    Microsoft Co-Sponsors Submission of Office Open XML Document Formats to Ecma International for Standardization”.

Previous post:

Next post: