Welcome Guest, Not a member yet? Register   Sign In
CSS problem
#1

[eluser]dianikol85[/eluser]
Hi to all. I'm new to Codeigniter. Ireally like it. So i have a css issue. I have a view header.php where i put this line of code

<link rel="stylesheet" href="<?php echo base_url();?>/css/style.css" type="text/css" media="screen" /> . but it can't find the style.css. The path is right.

Any suggestions????
#2

[eluser]mddd[/eluser]
If the path was right it would find it... ;-)
My guess: base_url() is supposed to end in a slash (check config.php!)
So your url is now probably www.yoursite.com//css/style.css or something like that.
#3

[eluser]dianikol85[/eluser]
in the source code it generates http://ci-tut.loc/css/style.css ( i use virtual hosts ) which is the correct path. In the config file i set

$config['base_url'] = "http://ci-tut.loc/"; and also

$config['index_page'] = ""; to get rid of index.php. i also write the .htaccess to do it so it is correct.

Still nothing... i alse put the application folder out of the system folder. but i dont think this is an issue.
#4

[eluser]mddd[/eluser]
IIf the uri looks ok, your browser has probably cleaned it up for you?
Anyway, you are not by accident rewriting ALL your urls are you? You should make exceptions for css, images etc. in your htaccess.
Otherwise a call to /css/style.css will be rewritten to /index.php/css/style.css and that will not work..
#5

[eluser]dianikol85[/eluser]
i just use the htaccess from the user guide. Does it need anything more?
#6

[eluser]mddd[/eluser]
You mean this?
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

As you can see, this will rewrite any url that doesn't start with index.php, images or robots.txt.
So yes, a url starting with css will be rewritten and therefore not work.

You should add files/folders that should not be rewritten to the exclusions.
There are other solutions too, like excluding anything that is a 'real file' from the rewriting.
#7

[eluser]dianikol85[/eluser]
yes, that should be the reason. Anywway i am not familiar with the htaccess file so i dont know what to add in there Sad
#8

[eluser]mddd[/eluser]
Basically you want every address to be rewritten with index.php so it goes to CI.
Except for normal files like images, javascript, css etc.
For every folder of normal files you have on your site (/css, /images etc) you add the name in the RewriteCond line.
So to add css that becomes
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|css|images|robots\.txt|favicon)
RewriteRule ^(.*)$ /index.php/$1 [L]
I've added 'favicon' in there as well because that too is a file that should not be tried through CI of course.
#9

[eluser]InsiteFX[/eluser]
Take the / off, your base url already has an ending /.

/css/style.css

Should be:

css/style.css

InsiteFX
#10

[eluser]dianikol85[/eluser]
thank you mdd. It works! thank you all for being so quick with your applies Wink




Theme © iAndrew 2016 - Forum software by © MyBB