0

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:

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.

This is my .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>

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

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.

The folder structure is like this:

   application
       controller
       model
       view
           header.php
           index.php
           footer.php
       .htaccess
   system
   assets
       css
       fonts
       images
       js
j08691
  • 204,283
  • 31
  • 260
  • 272
Tywele
  • 485
  • 1
  • 7
  • 21
  • `http://::1`? If you're loading the site via an IPv4 address, then an IPv6-hosted resource (even if it's the same physical server) would trigger a cross-origin rejection. so if `http://localhost` ends up going out on `http://127.0.0.1`, then there's your problem... – Marc B Jan 25 '16 at 17:34
  • And how do I fix that? – Tywele Jan 25 '16 at 17:38
  • quick/easy/dirty? disable ipv6. that or make sure everything goes out via one of the protocols only, not both. – Marc B Jan 25 '16 at 17:43
  • @Tywele post your htaccess too – Abdulla Nilam Jan 25 '16 at 18:43

3 Answers3

5

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

Tywele
  • 485
  • 1
  • 7
  • 21
1

You need to add the base URL to your configuration file:

$config['base_url'] ='http://www.urlname.com';

We can set this way so we can move any server no need to change try this one.

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
Siddharth Shukla
  • 1,063
  • 15
  • 14
0

Allowing cross-site scripting may cause security issues, try to adjust your codeigniter options;

1.) Go to application/config/config.php file, 2.) find $config['base_url'] = ""; and 3.) place your project folder's path as value. $config['base_url']="http://localhost/yourProjectFolder/";

noushad mohammed
  • 375
  • 1
  • 4
  • 20