0

I have made a codeigniter application. I uploaded it to http://www.domain.com.

But Chrome continuously give the message...

Font from origin http://www.domain.com has been blocked from loading by Cross-Origin Resource Sharing policy. Origin 'http://domain.com' is therefore not allowed access.

I set my base_url in config.php as http://www.domain.com but the error still persists.

When I changed the base_url as http://domain.com, it gives error as...

Font from origin http://domain.com has been blocked from loading by Cross-Origin Resource Sharing policy. Origin 'http://www.domain.com' is therefore not allowed access.

I've written the below code in my web.config, but no result.

<staticContent>
    <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 IST" cacheControlMode="UseExpires" />
    <remove fileExtension=".woff" /> <!-- In case IIS already has this mime type -->
    <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
    <remove fileExtension=".eot" />
    <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
</staticContent>

I have seen a, b, c these links, but unable to resolve.

What should I do ?

UPDATE

Actually the error comes from the domain name. If I write www.domain.com while my config.php base_url() is http://domain.com, it gives the error. On the other hand, if my If I write domain.com while my config.php base_url() is http://www.domain.com, it also gives the error.

Community
  • 1
  • 1
Raja
  • 772
  • 1
  • 15
  • 38
  • download the font folder and add it in your file structure will solve this problem – Abdulla Nilam Sep 05 '16 at 04:48
  • @Spartan thanks for the answer, but for your information, font folder is inside the file structure. Please see the update. – Raja Sep 05 '16 at 04:49

1 Answers1

1

The issue resolved. (I don't know whether it gives another error in future)

Solution #1 (Probably the best solution):

For IIS 7 : (Source: Enable Cross-Origin Resource)

Add the below code in your web.config file...

<system.webServer>
 <httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
  </customHeaders>
 </httpProtocol>
</system.webServer>

For IIS 6: CORS on IIS6

For Apache : CORS on Apache

For other platform: CORS support to server


Solution #2 (I don't know whether it works in all servers, but for me it worked well.)

Source: Codeigniter base url issue with www

Configure your base_url in codeigniter config/config.php file

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
Community
  • 1
  • 1
Raja
  • 772
  • 1
  • 15
  • 38