【问题标题】:Apache Config Mime Types: xlsx files are being interpreted as zip files on download, why?Apache Config Mime 类型:xlsx 文件在下载时被解释为 zip 文件,为什么?
【发布时间】:2009-10-30 00:21:28
【问题描述】:

背景: 出于某种原因,每当用户尝试使用 MSIE 从我们的 Intranet 打开 xslx (excel 2007) 文件时,文件下载对话框会将其解释为“zip”文件。

诚然,xslx 文件确实 zip 文件,但我们不希望这种行为。请在 Excel 中打开。

问题:

Firefox,OTOH,正常打开文件。是否有可能是我的 apache 配置错误?还是这是仅限客户端浏览器的问题?

【问题讨论】:

    标签: apache excel zip mime-types


    【解决方案1】:

    您必须在网络服务器端添加一些新的 MIME-TYPES。

    参见comment-thread on this windowsnerd.com page(自 2009 年起):

    将其添加到 .htaccess 文件并将其放到您的网站上:AddType 应用程序/vnd.openxmlformats .docx .pptx .xlsx .xltx 。 xltm .dotx .potx .ppsx

    应该可以解决很多问题。

    或者,您可以将其添加到位于 Apache Web 服务器的 config 目录中的 mime.types 文件中

    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
    

    http://www.webdeveloper.com/forum/showthread.php?t=162526

    【讨论】:

      【解决方案2】:

      原因是 IE 奇怪的 MIME 嗅探行为:http://msdn.microsoft.com/en-us/library/ms775147.aspx。它基本上试图通过查看文件的内容来确定文件的文件类型,有点像 Linux 的 file 工具。

      【讨论】:

      • 那么,您知道吗,有没有办法禁用此功能或重新配置浏览器以停止此行为?
      猜你喜欢
      • 2023-04-08
      • 1970-01-01
      • 2011-10-22
      • 2016-11-23
      • 2010-11-07
      • 2011-09-29
      • 2018-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多