CodeIgniter Forums

Full Version: Problem Loading CSS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]edelcal[/eluser]
I'm building a website and I'm having a hard time loading a stylesheet. If I place it within the images folder (which is in the root folder), everything works just fine, but if I create a folder called "styles" or whatever other name and place the css file in it, the page refuses to load the stylesheet, even though the path is 100% correct.

Why does it only work when the stylesheet is inside the images folder but not when it's placed in any other folders? Does it have anything to do with setting permissions or something like that? I don't remember doing anything special with the images folder, but somehow it's the only one that can hold the stylesheet as of right now.

Even funnier, when I place the stylesheet in the root folder, it doesn't work either! I am sure the paths are 100% correct. I have a view called "header" that is loaded in every page, and that's where I set the path for the stylesheet.

Any help would be really appreciated. It's driving me crazy!! Confusednake:

El Forum

[eluser]tomdelonge[/eluser]
It's probably your .htaccess file. Some of the example files allow stuff from the image folder, otherwise it is routed through the index.php file. Just add a style folder to your list of allowed paths in your .htaccess

Good luck, hope that helps...

El Forum

[eluser]slowgary[/eluser]
It's almost definitely your .htaccess file. It varies based on server configuration, but my htaccess looks like this:
Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
#RewriteCond $1 !^(index\.php|cms|assets|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

The !f, !d, !l lines make the rewrite only work when there is not an actual file or directory at that location. This might help for you.

Good luck.

El Forum

[eluser]edelcal[/eluser]
Thank you so much tomdelonge! It worked. So basically the problem was my htaccess file, which didnt have the styles folder listed. I learned a lot today!

El Forum

[eluser]edelcal[/eluser]
Thanks slowgary! that was definitely the issue. :-)