关于WordPress主题中.cur和.woff文件MIME type的设置

WordPress主题中使用了.woff格式的ICON字体文件,在查看Chrome的Console时,发现了Warning信息:

Resource interpreted as Font but transferred with MIME type application/octet-stream …
Resource interpreted as Image but transferred with MIME type application/octet-stream …

解决方法如下:
对于WOFF fonts,目前来说可用的mime 类型是

application/x-font-woff

而对于 .cur和 .ico 文件来说,目前可用来避免警告信息的是

image/vnd.microsoft.icon

PHP:

#对woff font
header(“Content-Type: application/x-font-woff”);
#对.cur文件
header(“Content-Type: image/vnd.microsoft.icon”);

Apache
对于Apache ,可修改mime.types文件,加上:

application/x-font-woff woff
image/vnd.microsoft.icon cur

没有权限修改配置文件的话,可在目录下面放一 .htaccess文件,加上:

AddType application/x-font-woff .woff
AddType image/vnd.microsoft.icon .cur

0 Comments
Leave a Reply