Welcome Guest, Not a member yet? Register   Sign In
Help needed with css file - Solved
#1

[eluser]eyalpor[/eluser]
i am new to CI, and have this ongoing problem: CI will not recognize my css file.
I searched and tried many posts over the web, but nothing does it.
Here is the configuration:
I work on localhost, the CI library is "myblog" and it is configured OK in config file. I can see the page, but the css does not apply.
Per suggestions on the web, my css file (style.css) is in css/style.css on the root directory :
localhost/myblog/css
I call the file in header:
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css" media="screen" >
which brings the expected outcome:
<link rel="stylesheet" type="text/css" href="localhost/myblog/css/style.css" media="screen">
Nada.
I have a htaccess file with only "Deny from all" in it under application library.
What am I doing wrong?
#2

[eluser]michalsn[/eluser]
Check your main .htaccess file and add "css" directory to allowed items.

Code:
RewriteCond $1 !^(index\.php|css|robots\.txt)
#3

[eluser]eyalpor[/eluser]
Hello Grad Student, thanks for the reply.
My .htaccess file now looks:

Deny from all

RewriteEngine on
RewriteCond $1 !^(index\.php|css|robots\.txt)

Nothing.
(I am very ignorant about the .htaccess files, so maybe something there is wrong also?)
#4

[eluser]sanir[/eluser]
hi,

Please check base URL in config file, it should be http://localhost/myblog/ instead of localhost/myblog/

Thanks,
Nasir Ranta
#5

[eluser]Sanjay Sarvaiya[/eluser]
Code:
<link rel=“stylesheet” type=“text/css” href=”<?php echo base_url(); ?>css/style.css”  media=“screen” >
//which brings the expected outcome:
<link rel=“stylesheet” type=“text/css” href=“localhost/myblog/css/style.css” media=“screen”>
//outcome will be with http://
<link rel=“stylesheet” type=“text/css” href=“http://localhost/myblog/css/style.css” media=“screen”>
Its mean that your base url is
Code:
$config['base_url'] = 'localhost/myblog/';
// base url must be start with http://
$config['base_url'] = 'http://localhost/myblog/';
#6

[eluser]eyalpor[/eluser]
Thank you very much guys!
The (tiny) problem was indeed the http:// in the beginning of the base_url config.
Yet another reminder of why to choose PHP - great community.




Theme © iAndrew 2016 - Forum software by © MyBB