Azure 网站中未显示很棒的字体

Font awesome not shown in Azure website

我按照 here

的说明在 Microsoft Azure 网站云中部署了一个 symfony 项目

项目成功,但 "font awesome" 和其他字体文件的元素未显示。我试图修改 web.config 文件添加这个:

<httpProtocol>
     <customHeaders>
          <add name="Access-Control-Allow-Origin" value="*" />
          <add name="Access-Control-Allow-Methods" value="HEAD,GET,OPTIONS" />
     </customHeaders>
</httpProtocol>

还有这个:

<staticContent>
     <remove fileExtension=".svg" />
     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
     <remove fileExtension=".eot" />
     <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
     <remove fileExtension=".woff" />
     <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
     <remove fileExtension=".woff2" />
     <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

但是问题还是没有解决

完整的 web.config 文件是:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
                <add name="Access-Control-Allow-Methods" value="HEAD,GET,OPTIONS" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <remove fileExtension=".svg" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <remove fileExtension=".eot" />
            <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="app.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <clear />
                <rule name="blockAccessToPublic" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{URL}" pattern="/web/*" />
                    </conditions>
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
                </rule>
                <rule name="RewriteAssetsToPublic" stopProcessing="true">
                    <match url="^(.*)(\.css|\.js|\.jpg|\.png|\.gif)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    </conditions>
                    <action type="Rewrite" url="web/{R:0}" />
                </rule>
                <rule name="RewriteRequestsToPublic" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    </conditions>
                    <action type="Rewrite" url="web/app.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

使用 Fiddler,我看到引用字体文件的 url 有 404 错误,但我知道它们存在,我可以在调试控制台中看到它们。

¿可能是什么问题?

我将从您的 re-write 规则开始。尝试消除它们并查看 404 文件错误是否仍然出现。如果之后文件有效,re-introduce 每个 re-write 一个一个地规则,直到找到罪魁祸首。

此外,您可以删除自定义 headers,静态内容部分看起来是正确的。