.woff2字体使用正确的mimemap返回404错误?

时间:2018-09-08 21:59:05

标签: css iis fonts woff2

我的服务器上有一个.woff2字体,该字体不断返回404错误。经过研究,我发现我需要有一个mimeMap标记来告诉服务器如何为其服务。我添加了它,它运行良好,然后注释掉了重写规则,此后它停止了工作。但是取消重写规则的注释不会使其再次起作用,其他任何更改都没有。这是我的web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
    <sectionGroup name="system.webServer">
        <sectionGroup name="rewrite">
            <section name="rewriteMaps" overrideModeDefault="Allow" />
            <section name="rules" overrideModeDefault="Allow" />
        </sectionGroup>
    </sectionGroup>
</configSections>

<system.webServer>
    <security>
        <!--  This section should be uncommented after
        installation to secure the installation. -->
        <requestFiltering>
            <hiddenSegments>
                <add segment="assets"/>
                <add segment="cms"/>
                <add segment="includes"/>
            </hiddenSegments>
            <fileExtensions>
                <add fileExtension=".woff" allowed="true" />
                <add fileExtension=".ttf" allowed="true" />
                <add fileExtension=".woff2" allowed="true" />
             </fileExtensions>
        </requestFiltering>
    </security>
    <directoryBrowse enabled="true" />
    <caching>
        <profiles>
            <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
            <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00:00" />
        </profiles>
    </caching>
    <rewrite>
        <!--<rules>
            <rule name="block favicon" stopProcessing="true">
                <match url="favicon\.ico" />
                <action type="CustomResponse" statusCode="404" subStatusCode="1" 
                    statusReason="The requested file favicon.ico was not found" 
                    statusDescription="The requested file favicon.ico was not found" />
            </rule>
            <rule name="Imported Rule 1" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^example\.com$" />
                </conditions>

                <action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}" />
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
            </rule>
        </rules>-->
    </rewrite>
    <defaultDocument>
        <files>
            <remove value="index.php" />
            <add value="index.php" />
        </files>
    </defaultDocument>

    <staticContent>
        <remove fileExtension=".woff2" />
        <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
    </staticContent>

    <!-- HTTP Errors section should only be enabled if the "Error Pages"
    feature has been delegated as "Read/Write" at the Web Server level.
       <httpErrors>
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
       </httpErrors>
    -->

</system.webServer>

服务器为IIS7 +,服务器上确实存在字体,路径正确。怎么了?请帮助。

0 个答案:

没有答案