百度云加速font/ttf字体文件,跨域/不同域名下无法正常工作,debug发现错误代码类似:
Font from origin 'http://cdn.ctohome.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.ctohome.com' is therefore not allowed access.
最安全的解决办法,就是到ttf或woff字体文件目录下,如 /home/cdn/public_html/themes/www.ctohome.com/iconfont 创建一个.htaccess文件,设置Header add Access-Control-Allow-Origin "*" 这样就可以把header头传送到百度云加速,支持跨域名调用ttf或woff字体文件了。注意,不要把.htaccess文件放到除了字体以外的其他目录,防止有安全隐患。
[[email protected]]# pwd
/home/cdn/public_html/themes/www.ctohome.com/iconfont
[[email protected]]# vi .htaccess
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Credentials 'true'
Header add Access-Control-Allow-Methods 'GET'
注意: Access-Control-Allow-Origin 只能有一条记录,不可以重复