【问题标题】:404 not found for a PDF on my Azure app在我的 Azure 应用程序上找不到 PDF 的 404
【发布时间】:2015-10-06 17:15:32
【问题描述】:

我目前正在 Azure 服务器上运行我的第一个 Symfony 应用程序,并且遇到了一个关于 PDF 文件的问题。

我的网站上有一个链接直接指向 PDF 文件 (http://[mywebsite].azurewebsites.net/tcbesports.pdf),因此(例如在 Chrome 中)它可以在浏览器的本机 pdf 阅读器中打开。这在我的本地主机上运行得很好,但是当我将我的应用程序转移到 Azure 时,指向 PDF 的链接停止工作,我得到一个 404 未找到。

Oops! An Error Occurred

The server returned a "404 Not Found".

Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

但是,您可以清楚地看到我的文件夹中有该文件。因为当我访问另一个文件(例如http://[mywebsite].azurewebsites.net/favicon.png)时,该文件会显示出来。

但是,robots.txt 也不会被“找到”。这与文件的性质有关吗?我发现了一些关于 blob 文件的提及,但不知道如何进一步了解该信息..

非常感谢!

【问题讨论】:

    标签: symfony azure pdf


    【解决方案1】:

    如果您按 f12 并在您的网站上进行网络跟踪,您通常会在访问“非正常网络”文件时看到返回 404。

    您需要为 pdf 添加 MIME 类型。

    将以下 config.xml 放在您网站的根目录中。是的,PHP 事件在您的 Web 根目录中放置了一个 config.xml。如果 config.xml 已经存在,请合并 pdf 部分。注意我留下了一些其他类型,以便您可以看到更大的类型。可以在 http://www.feedforall.com/mime-types.htm 找到扩展及其 mimeType 的完整列表。

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".m4a" />
            <mimeMap fileExtension=".m4a" mimeType="audio/mp4a-latm"/>
            <remove fileExtension=".ogg" />
            <mimeMap fileExtension=".ogg" mimeType="application/ogg"/>
            <remove fileExtension=".pdf" />
            <mimeMap fileExtension=".pdf" mimeType="application/pdf"/>
        </staticContent>
    </system.webServer>
    </configuration>
    

    希望这会有所帮助。坦帕的希利

    【讨论】:

      猜你喜欢
      • 2016-07-01
      • 2020-08-09
      • 2018-07-06
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多