
在我的 Apache 伺服器上,我儲存了幾個 docx、xlsx pptx 檔案。
某些客戶端瀏覽器認為這些是常規 zip 文件,並在下載時更改文件副檔名。我該如何讓它不再這樣做。
(使用Ubuntu伺服器)
答案1
這些文件實際上是 XML 文檔的 ZIP。將其新增至 Apache 中的 .htaccess
AddType application/vnd.ms-word.document.macroEnabled.12 docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
答案2
伺服器沒有為新的 ms 檔案類型設定正確的 mime 類型
將以下內容新增至 /etc/mime.types 檔案並重新啟動 apache,問題應該會解決。
# Added by myname 2009-06-03
application/vnd.ms-word.document.macroEnabled.12 docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.ms-excel.template.macroEnabled.12 xltm
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
http://www.webdeveloper.com/forum/showthread.php?t=162526有關於這個問題的信息
答案3
聽起來您的網頁伺服器正在查看這些檔案中的神奇數字,並發現它們是 zip 檔案。
看一下:http://www.webdeveloper.com/forum/showthread.php?t=162526
答案4
下載http://packages.ubuntu.com/oneiric/mime-support,並使用 dpkg -i 安裝它。效果很好!
PS:Ubuntu 和 Debian 上的 Apache 從 /etc/mime.types 讀取