【问题标题】:MIME Types for woff, ttf, svg, and eot 404ing despite being setup in IISwoff、ttf、svg 和 eot 404ing 的 MIME 类型,尽管已在 IIS 中设置
【发布时间】:2014-11-28 10:43:58
【问题描述】:

我正在尝试获取要在文件中呈现的字体,这给了我通常的错误

Resource interpreted as Font but transferred with MIME type text/html:

但是展示的 HTML 文件是我们的 404.aspx 文件,我尝试了在 web.config 中安装应用程序的常规方法,然后最终安装到 IIS 本身中:

.woff  application/font-woff
.ttf   application/font-ttf
.eot   application/vnd.ms-fontobject
.otf   application/font-otf
.svg   image/svg+xml

我不明白我哪里出错了。这些文件存储在一个名为 fonts 的文件夹中,该文件夹位于站点的基本目录中,我的 aspx 文件中的样式为

@font-face {
    font-family: 'segoe_printregular';
    src: url('/fonts/segoepr-webfont.eot'); /* IE9 Compat Modes */
    src: url('/fonts/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/fonts/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
         url('/fonts/segoepr-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/fonts/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    font-weight: normal;
    font-style: normal;
}

字体文件夹中的 stylesheet.css 为:

@font-face {
    font-family: 'segoe_printregular';
    src: url('/segoepr-webfont.eot'); /* IE9 Compat Modes */
    src: url('/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
         url('/segoepr-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    font-weight: normal;
    font-style: normal;
    }

我已尝试将文件路径设置为 /fonts/ 并且只是 fonts/ 无济于事。但是我无法将文件设置为 bnot 404。有人建议重新启动服务器,但这也没有任何效果。

我有什么遗漏吗?还是我犯了什么错误?

如果有帮助,我也在 web.config 中尝试过

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

【问题讨论】:

标签: fonts iis-7.5 mime-types woff eot


【解决方案1】:

对于那些需要答案的人。下面是解决方案。详情请参考http://www.alienfactory.co.uk/articles/mime-types-for-web-fonts-in-bedsheet

<remove fileExtension=".woff" />
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".svg" />

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

【讨论】:

猜你喜欢
  • 2014-10-26
  • 2016-11-10
  • 2017-06-05
  • 2011-09-05
  • 2016-06-27
  • 2012-06-15
  • 2021-08-02
  • 2016-01-13
相关资源
最近更新 更多