gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 00:51:52 25 4
gpt4 key购买 nike

我按照 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 错误,但我知道它们存在,我可以在调试控制台中看到它们。

请问问题出在哪里?

最佳答案

我将从你的重写规则开始。尝试消除它们并查看 404 文件错误是否仍然出现。如果此后文件有效,则一一重新引入每个重写规则,直到找到罪魁祸首。

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

关于symfony - Azure 网站中未显示很棒的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32151062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com