ZhijieWang ZhijieWang - 3 years ago 163
CSS Question

Codeigniter + CSS not working well, possible baseurl

This question has been asked several times, but I researched and still can't solve it. In one of my view file, I have (referencing to my css):

link rel="stylesheet" type="text/css" href="/application/views/screen.css"

The css file is in:

- www
- application
- view
- css
- screen.css
- system

I also tried to setup the css in the same folder under
and use it directly by

link rel="stylesheet" type="text/css" href="css/screen.css"

My base
is set to
because I develop locally. Is this the issue? I'm Using wamp server.

So what is the problem? Can anyone help?

Answer Source

You can't put your CSS files or files to be served to browser in the application folder as it is protected for security reasons with a .htaccess file set to 'Deny from All' Your CSS, JS, image files etc, need to be outside of the application folder.

Put your CSS file in a folder called 'css' in the 'www' folder so it is NOT inside 'application' or 'system'. Then make sure you use the following (notice the leading slash, denoting an absolute URL):


Use this instead:

# If your default controller is something other than
# "welcome" you should probably change this
RewriteCond $1 !^(index\.php|css)
RewriteRule ^(.*)$ /index.php/$1 [L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download