Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I have to write to the .htaccess file so that the visitors will be able to download .docx files?

share|improve this question
So much more information required. Like why you think they can't download them now. – womble Dec 19 '09 at 1:44
I have added AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx to the .htaccess file, didn't worked and application/vnd.openxmlformats-officedocument.wordprocessingml.document docx to the mime.types under etc/ and etc/, did't worked. – ilhan Dec 19 '09 at 2:26
It works by this way: Run socalledoriginal.docx file as php (AddType application/x-httpd-php .docx) <?php header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="socalledoriginal.docx" '); // The PDF source is in original.pdf readfile('cv/original.docx'); ?> – ilhan Dec 19 '09 at 3:34
up vote 2 down vote accepted

Sounds like a browser configuration problem. Make sure your browser is configured to download files of the appropriate content type rather than trying to display them.

Also, you could try adding the Content-Disposition header, which can be done with the Header directive in Apache: Here's one explanation of how to use the header:

share|improve this answer

Are your docx files trying to be run as zip files from the client? Since Office2007 files are essentially just xml files zipped together, Unix treats them like regular zip files, due to their magic numbers. And thus Apache sends the wrong MIME type headers.

A rather succinct answer for this can be found in another serverfault question:

share|improve this answer
No, they are not run as a zip file but as a text file. – ilhan Dec 19 '09 at 21:04
I have already tried the method in the link, it didn't helped. – ilhan Dec 19 '09 at 21:08

This is an IE problem, but easy to solve in the .htaccess:

 <FilesMatch "\.(?i:docm|docx|xlsx|xlsm|xlsb|pptx|pptm|ppsx)$">
  Header set Pragma private

Make sure you don't use SSL (https) or iE gives an error

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.