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

link|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. – george 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'); ?> – george Dec 19 '09 at 3:34
feedback

3 Answers

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

link|improve this answer
feedback

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

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

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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