2

I just started using codeigniter and have got it setup so that it does not require index.php as part of the URL.

However, I noticed that the reference to font-awesome is not working correctly. The following is loading fine.

  <link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css" />

However, the font .eot, woff, etc... is not found and causing the icon to appear as a 404.

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

My config:

$config['base_url'] = '';

My .htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|css|woff|eot|ttf|svg|css|js|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Any help is appreciated.

edit the folder structure i have is:

codeigniter/
-->application/
-->assets/
---->plugins
---->plugins/font-awesome
---->plugins/font-awesome/css
---->plugins/font-awesome/fonts
-->system/
-->.htaccess
-->index.php
Rick
  • 555
  • 1
  • 12
  • 30

3 Answers3

3

Set your BaseUrl to you site url in config.php file like this

$config['base_url'] = 'http://localhost/ci';

or add this code to your config.php file

$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

this works for me 100% ;)

reference here

AmarBunty
  • 78
  • 6
0

Did you place the fonts folder in the same directory your fonts-awesome.css is placed .. you must make sure the folder ( fonts ) and the file font-awesome.css are in the same folder/directory ..

From your question , make sure the fonts folder is inside the css folder

JohnMi
  • 81
  • 1
  • 7
  • Hi RobyMi, I've provided my codeigniter folder structure. the assets is outside of the webroot. – Rick Feb 10 '15 at 00:35
  • yes I have seen your folder structure.. you must move the fonts folder to the css folder where your font-awesome. css file is saved, thats how font awesome sees the fonts unless you change the url pointing to the fonts folder to some other path. – JohnMi Feb 10 '15 at 07:56
0

I have a folder structure like yours but I have added in the css path the site base URL:

 <link href="<?php echo base_url('assets/plugins/font-awesome/css/font-awesome.css') ?>" rel="stylesheet">

I hope this works for you.

fructurj
  • 104
  • 1
  • 10