duangekui7451 2014-10-02 08:37 采纳率: 0%
浏览 152
已采纳

使用字体时出现跨域错误

I have come across an error when trying to access my site with http://www.example.com instead of http://eample.com. My font icons will not load. So when searching for the solution to this I came across the following solution which was adding the below code to a .htaccess file on the server.

<FilesMatch "\.(svg|ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "http://example.com, http://www.example.com"
</IfModule>

This managed to fix the problem but for Chrome only. How can i fix the issue for all browsers.

Thank you

  • 写回答

1条回答 默认 最新

  • doubleyou1001 2014-10-02 08:48
    关注

    Try using:

    href="/css/font-awesome.min.css"
    

    This will be relative to the domain they visitor is on, so if they connect to either http:// or http://www the fonts will load and there won't be a cross domain error

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看