Forcing IE7+ to download an XML file, using Apache2
little question that is going to take me mad!
I've an xml file that I want to download from a browser. I've set the correct mime type and attachment via Apache2 .htaccess
xpt is a file that has the first line as a regular xml file
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
My .htaccess looks like this
AddType application/octet-stream .xpt
<FilesMatch "\.(?i:xpt)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
Looking via Explorer Developer Tools (F12), the header in the Networks tabs looks correct. Every other browser has no problem, IE7+ yes.
Is there a soluti开发者_StackOverflow中文版on, without resort to a wrapper?
Is there anything that I've missed in my configuration?TIA
I've managed to find the solution, in this obscure thread from the drupal community: http://drupal.org/node/244852#comment-979530
My solution works as this:
AddType application/octet-stream .xpt
<FilesMatch "\.(?i:xpt)$">
ForceType application/force-download
Header set Content-Disposition attachment
Header set Content-Description File-Transfer
Header set Cache-Control "store, no-cache, must-revalidate"
</FilesMatch>
Still not understanding why IE7 has a behaviour so different from other browser. It ignore also the application/octet-stream when received as an header.
It looks like you are an the right track, but do your XML files have the .xpt extension? Also check the MIME.
AddType text/xml .xml
<FilesMatch "\.(?i:xml)$">
ForceType text/xml
Header set Content-Disposition attachment
</FilesMatch>
精彩评论