字体很棒,没有在Azure网站上显示

时间:2015-08-22 00:25:01

标签: symfony azure fonts font-awesome

我按照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,我看到引用字体文件的网址有404个错误,但我知道它们存在,我可以在调试控制台中看到它们。

¿问题可能是什么?

1 个答案:

答案 0 :(得分:4)

我会从你的重写规则开始。尝试删除它们,看看404文件错误是否仍然显示。如果文件在此之后工作,请逐个重新引入每个重写规则,直到找到罪魁祸首。

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