Code Igniter : base_url() at CSS file doesn't work
You should do it like this
Structure of your files
myapp/ application/ system/ css/ img/
And in css write this
body { background:#356aa0 url(../img/background.png) repeat-x; color:#fff;}
And now call it
<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/style.css"/>
That is the standard way of doing it. Also your css is not dynamic so you dont have to worry about php code using in it. The structure i presented in the answer will surely use the styles correctly and load the images.
Get your base_url() out of the CSS file. That would fix the problem. You can't put PHP code in a CSS file.
CSS file does not get parse as PHP file. If you really want to do something like that, rename your file as styles.php
OPEN the page and add
header("content-type: text/css");
This tells the page to be treated as a text based CSS file. Then you can simple echo your remaining CSS like
echo "body {........";
To fix the base_url()
not being accessible from styles.php
set a session variable to keep that. You can keep this on your index.php
of codeignitor.
$_SESSION['base_url'] = base_url();
Now, use this inside styles.php
.
background: url("<?php echo $_SESSION['base_url']; ?>"/../../some.jpg");