STUDY WHILE YOU ARE BORING


  • 首頁

  • 搜索

  • 技术

  • Tags

  • 关于我

CSS 字体(例如font-awesome),子域名不能正确显示

發表於 December 15, 2016   |   作者: Tim   |   分类: 技术   |   评论

症状

原来能正常显示的情况下,将js、css、图片文件改为子域名访问,方便cdn加速。切换之后一切正常,但是font-awesome的图片没有正确显示,全部显示框框

原因

因为浏览器的安全规则,虽然是子域名,但是css跨域载入字体文件的时候被浏览器拦截,导致了显示不正常。

解决

以apache为例,修改.htaccess或者 httpd.conf

<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>
apache, css, font-awesome
Say Yes 吉他solo
让spotlight 显示中英翻译

钜添

54 文章
2 分類
1 页面
GitHub 日记技术
php apache centos macos mysql https shadowsocks mac 微信 ups svn javascript outline accesskey Chrome Extension letsencrypt ssl free certification certbo wildcard renew cloudflare pgsql 归档 binlog isset array_key_exists redmine axure
© 2021 钜添   |   文章 RSS     |  登录
由 Typecho 强力驱动
主題 - NexT
Send message encrypted and private - Msg2
Build your Under Construction Page without hosting - UnderConstruct.IO