<system.webServer>
<staticContent>
<!-- remove first in case they are defined in IIS already, which would cause a runtime error -->
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
</system.webServer>
For all Solution index.php remove form url and woff file allowed. for write below code in .htaccess file and and make this alternation to your application/config/config.php file: $config['index_page'] = '';
For only Linux hosting server..htaccess file details
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
17 回答
Mime类型可能不是您唯一的问题 . 如果字体文件托管在S3或其他域上,您可能还会遇到Firefox不会从不同域加载字体的问题 . 这是Apache的一个简单修复,但在Nginx中,我已经读过你可能需要在base-64中编码你的字体文件并将它们直接嵌入你的font css文件中 .
Update from Keith Shaw's comment on Jun 22, 2017:
在2011年1月it was announced,同时Chromium将承认
application/x-font-woff
作为WOFF的哑剧型 . 我知道这个变化现在已经在Chrome测试版中,如果还没有稳定,那么它应该不会太远 .
对我来说,下一个是在.htaccess文件中工作 .
它将是
application/font-woff
.见http://www.w3.org/TR/WOFF/#appendix-b(W3C候选人推荐2011年8月4日)
和http://www.w3.org/2002/06/registering-mediatype.html
From Mozilla css font-face notes
来源:https://developer.mozilla.org/en/CSS/@font-face#Notes
将字体mime类型添加到.NET / IIS的参考
via web.config
via IIS Manager
NGINX SOLUTION
文件
要么
加
去掉
REFERENCES
RFC @ 02.2017
https://tools.ietf.org/html/rfc8081#page-15
https://www.iana.org/assignments/media-types/media-types.xhtml
感谢Mike Fulcher
http://drawingablank.me/blog/font-mime-types-in-nginx.html
截至2017年2月,RFC8081是拟议标准 . 它定义了字体的顶级媒体类型,因此WOFF和WOFF2的标准媒体类型如下:
没有
font
MIME类型!因此,font/xxx
总是错的 .@Nico ,
目前,没有为woff字体mime类型定义的标准 . 我使用字体传递cdn服务,它使用font / woff,我在chrome中得到相同的警告 .
参考:The Internet Assigned Numbers Authority
对我这样做的事情是将它添加到我的mime_types.rb初始化器:
and 清除缓存
在重新启动服务器之前 .
资料来源:https://github.com/sstephenson/sprockets/issues/366#issuecomment-9085509
也许这会对某人有所帮助 . 我在IIS 7上看到
.ttf
已经是一个已知的mime类型 . 它被配置为:所以我刚刚添加了所有CSS字体类型(
.oet
,.svg
,.ttf
,.woff
),IIS开始为它们提供服务 . Chrome开发工具也不会抱怨重新解释类型 .干杯,迈克尔
将以下内容添加到.htaccess中
祝好运
WOFF:
Web Open字体格式
可以使用TrueType或PostScript(CFF)轮廓进行编译
目前FireFox 3.6支持它
尝试添加:
IIS自动将.ttf定义为application / octet-stream,它似乎工作正常,而且fontshop建议将.woff定义为application / octet-stream
For all Solution index.php remove form url and woff file allowed. for write below code in .htaccess file and and make this alternation to your application/config/config.php file: $config['index_page'] = '';
For only Linux hosting server. .htaccess file details
我知道这篇文章有点陈旧但是花了很多时间试图让我的nginx本地机器上的字体工作并尝试了大量的解决方案后我终于得到了一个对我有用的东西就像一个魅力 .
在括号内,您可以放置字体的扩展名,或者通常是要加载的文件 . 例如,我用它来表示字体和图像(png,jpg等),所以不要混淆这个解决方案只适用于字体 .
只需将它放入你的nginx配置文件,重启,我希望它也适合你!
我遇到了同样的问题, font/opentype 为我工作