Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/mydomain.com, 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

3 Answers 3

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: http://httpd.apache.org/docs/2.2/mod/mod%5Fheaders.html#header Here's one explanation of how to use the header: http://support.microsoft.com/kb/260519

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: http://serverfault.com/questions/19060/why-are-docx-xlsx-pptx-downloading-from-webserver-as-zip-files

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

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

share|improve this answer

Your Answer

 
discard

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.