配置Windows Azure网站PHP应用程序的MIME类型

11

我正在使用Windows Azure Websites来托管一个php应用程序。我的应用程序使用webfonts(css3特性),我需要配置扩展名如.eot和.woff以避免404错误。我知道在.net应用程序中可以使用web.config设置这种配置,但对于php站点,我该怎么办?不幸的是,网站没有RDP。有没有其他解决方案?

2个回答

29

我只需要在根文件夹下添加一个web.config文件,就能解决这个问题。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
            <remove fileExtension=".ttf" />
            <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
            <remove fileExtension=".svg" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
        </staticContent>
    </system.webServer>
</configuration>

2
在woff的mime类型上经过了很多混淆,官方W3规范指出应该是"application/font-woff"而不是"x-application/font-woff"。 - Jeff Lewis

0
对于任何来到这里的人,我也遇到了woff2文件的问题,并通过在根目录中添加这个web.config文件来解决错误。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
        </staticContent>
    </system.webServer>
</configuration>

通过使用kudu服务,按照此处所述的步骤将文件添加到wwwroot目录中: http://www.jamessturtevant.com/posts/How-to-add-edit-and-remove-files-in-your-azure-webapp-using-the-kudu-service-dashboard/

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接