1

I want to load awesome.css in my php file. I have a code like this in my php :

<link rel="stylesheet" type="text/css" href="<?php echo base_url('resources/web2/lib/css/awesome.css'); ?>"/>

But when I check the awesome.css file, there is a code which have link to another url :

@font-face{font-family:'FontAwesome';src:url('../resources/web2/lib/font/FontAwesome/fontawesome-webfontf77b.eot?v=3.2.1');src:url('../font/FontAwesome/fontawesome-webfontd41d.eot?#iefix&v=3.2.1') format('embedded-opentype'),url('../font/FontAwesome/fontawesome-webfontf77b.woff?v=3.2.1') format('woff'),url('../font/FontAwesome/fontawesome-webfontf77b.ttf?v=3.2.1') format('truetype'),url('../font/FontAwesome/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg');font-weight:normal;font-style:normal;}

And when I load the page in web browser there is an error like this :

downloadable font: download failed (font-family: "FontAwesome" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed source: http://[::1]/yisc/resources/web2/lib/font/FontAwesome/fontawesome-webfontf77b.eot?v=3.2.1`

Please kindly help me to solved this issue, I really don't understand what happens here.

  • Possible duplicate of [Downloadable font on firefox: bad URI or cross-site access not allowed](http://stackoverflow.com/questions/15024333/downloadable-font-on-firefox-bad-uri-or-cross-site-access-not-allowed) – Alok Patel Aug 16 '16 at 12:49

3 Answers3

0

Go to config.php and set the baseurl

$config['base_url'] = 'https://stackoverflow.com/';

Its better to take look at Codeigniter Documentation about Base Url


src:url('../font/ depends on the folders you are being. Check Path (computing) in wiki

Panda
  • 6,955
  • 6
  • 40
  • 55
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • I left the config for the base url blank : $config['base_url'] = ''; since it is stated that "If this is not set then CodeIgniter will try guess the protocol, domain and path to your installation – White Mask Guy Aug 16 '16 at 12:52
  • @WhiteMaskGuy Its wrong Buddy. You have to set base Url – Abdulla Nilam Aug 16 '16 at 12:52
  • Hi, i updated the config like you suggest, but i still got the error message : `downloadable font: rejected by sanitizer (font-family: "FontAwesome" style:normal weight:normal stretch:normal src index:0) source: http://localhost/yisc/resources/web2/lib/font/FontAwesome/fontawesome-webfontf77b.eot?v=3.2.1` – White Mask Guy Aug 16 '16 at 12:56
  • 1
    @WhiteMaskGuy This is a case of Experience over Theories. Try setting the base_url as suggested and see what happens. Chances are that whether it works or not; it is just worth trying out (if only to confirm that it is relevant, at the least). – Poiz Aug 16 '16 at 12:57
  • remove these `?v=3.2.1` and check path is active `resources/web2/lib/‌​font/FontAwesome/font‌​awesome-webfontf77b.e‌​ot` – Abdulla Nilam Aug 16 '16 at 12:58
  • @Poiz Ok, Sorry. But I already add it, but it still show me the same error message, not exactly the same though. – White Mask Guy Aug 16 '16 at 13:00
  • @WhiteMaskGuy as i know your font awesome is wrong. check this link https://github.com/FortAwesome/Font-Awesome/tree/master/fonts – Abdulla Nilam Aug 16 '16 at 13:01
  • @Spartan I got this error message `downloadable font: rejected by sanitizer (font-family: "FontAwesome" style:normal weight:normal stretch:normal src index:0) source: http://localhost/yisc/resources/web2/lib/font/FontAwesome/fontawesome-webfontf77b.eot?v=3.2.1` – White Mask Guy Aug 16 '16 at 13:02
  • @Spartan I'll try to download the font file on the link that you provide and update the status after that. Wait a moment. – White Mask Guy Aug 16 '16 at 13:06
  • @WhiteMaskGuy load CDN style too `https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css` – Abdulla Nilam Aug 16 '16 at 13:07
  • @Spartan Hi, spartan, there is 2 file .eot which loaded in the css file, fontawesome-webfontf77b.eot and fontawesome-webfontd41d.eot , do i have to change both of it with the same eot file in the download link ? fontawesome-webfont.eot , i actually take a random html template from internet and try to apply it in codeigniter. – White Mask Guy Aug 16 '16 at 13:16
  • @WhiteMaskGuy i ner heard of name like that in font awesome. reomve those and check. think no problem with it – Abdulla Nilam Aug 16 '16 at 13:20
  • @WhiteMaskGuy happy to help :) – Abdulla Nilam Aug 18 '16 at 15:09
0

If this is what you actually have in your real code:

    <link rel="stylesheet" type="text/css" 
         href="<?phpechobase_url('resources/web2/lib/css/awesome.css'); ?>"/>`

Something is not quite OK.... the echo Part seems to form one word with base_url

You may consider putting a space between echo and base_url() instead:

    <link rel = "stylesheet" type="text/css" 
         href = "<?php echo base_url('resources/web2/lib/css/awesome.css'); ?>"/>
Poiz
  • 7,611
  • 2
  • 15
  • 17
0

i have same this problem just go to Application floder and go to config after that choose autoload.php

In this autoload.php page search about ($autoload['helper']) = array() you should replace to ($autoload['helper']) = array('url');

jrswgtr
  • 2,287
  • 8
  • 23
  • 49
feras
  • 1