duangekui7451 2014-10-02 00:37 采纳率: 0%
浏览 153
已采纳

使用字体时出现跨域错误

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 00: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

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部