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 -www
and use it directly by
link rel="stylesheet" type="text/css" href="css/screen.css"
My base url
is set to ""
because I develop locally. Is this the issue? I'm Using wamp server.
So what is the problem? Can anyone help?
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):
href="/css/screen.css"
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]
Bearing in mind there are several ways to skin a cat.
Quick fix without messing with htaccess. Use base_url() or site_url():
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/screen.css">
And use the following file structure:
www
application
system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With