跨源资源共享策略在CodeIgniter应用程序中阻止Bootstrap中的字形 [英] Cross-Origin Resource Sharing policy blocking glyphicons from Bootstrap in CodeIgniter application

查看:649
本文介绍了跨源资源共享策略在CodeIgniter应用程序中阻止Bootstrap中的字形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Bootstrap 3.3.6提供的字形,但Chrome阻止使用此错误消息访问它们:

I'm trying to use the glyphicons provided by Bootstrap 3.3.6 but Chrome is blocking the access to them with this error message:


来自 http:// [:: 1] 的字体已被跨原文加载阻止资源共享策略:在请求的资源上没有Access-Control-Allow-Origin头。原因 http:// localhost 因此不允许访问。

Font from origin 'http://[::1]' 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://localhost' is therefore not allowed access.

这是我的 .htaccess

   <IfModule authz_core_module>
      Require all denied
   </IfModule>
   <IfModule !authz_core_module>
      Deny from all
   </IfModule>
   <FilesMatch "\.(ttf|otf|eot|woff)$">
      <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
      </IfModule>
   </FilesMatch>

我做错了什么?我编辑错误的 .htaccess

What am I doing wrong? Am I editing the wrong .htaccess?

我也尝试添加 -Control-Allow-Origin:*); header.php 文件的开头,但是没有工作。

I also tried adding header("Access-Control-Allow-Origin: *"); at the beginning of my header.php file but that didn't work either. I'm out of ideas.

文件夹结构如下:

   application
       controller
       model
       view
           header.php
           index.php
           footer.php
       .htaccess
   system
   assets
       css
       fonts
       images
       js


推荐答案

我发现了问题:我没有设置base.urp在config.php从CodeIgniter。设置完成后,一切正常。

I found the issue: I didn't set the base_url in the config.php from CodeIgniter. After setting it everything works.

这篇关于跨源资源共享策略在CodeIgniter应用程序中阻止Bootstrap中的字形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆