CodeIgniter Forums
I can't show any css or images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: I can't show any css or images (/thread-40531.html)



I can't show any css or images - El Forum - 04-11-2011

[eluser]gunnarflax[/eluser]
Hi, I've started working with CodeIgniter today and I'm having some trouble with applying css rules and getting images to show. I've searched the internet and the forums but haven't found an answer to my question. I use this
Code:
link_tag('style/style.css', 'stylesheet', 'text/css')
to create the link tag but somehow the rules aren't applied to elements. When I create an image with the img() function it won't show either. I think there is a problem with the site trying to route to the controller "style" and the function "style.css" since the url is "style/style.css" but I don't know for certain and I don't know how I should do to change this behaviour.

The style folder is located in root, at the same directory level as the applications and system folder.

Please help me out here? Smile


I can't show any css or images - El Forum - 04-11-2011

[eluser]bubbafoley[/eluser]
can you access the stylesheet directly?

ie: http://example.com/style/style.css


I can't show any css or images - El Forum - 04-11-2011

[eluser]gunnarflax[/eluser]
Nope, I just get redirected to the index page :/


I can't show any css or images - El Forum - 04-11-2011

[eluser]bubbafoley[/eluser]
are you using an htaccess file to remove index.php from the url? sounds like that might be the problem.


I can't show any css or images - El Forum - 04-11-2011

[eluser]gunnarflax[/eluser]
yep, that was it. Does this mean that I cannot remove the index.php from the url without being unable to link files and images?


I can't show any css or images - El Forum - 04-11-2011

[eluser]d1a8lo24[/eluser]
Try the following .httaccess and see if it works.

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>



I can't show any css or images - El Forum - 04-11-2011

[eluser]gunnarflax[/eluser]
That worked when I tried it out now Smile Hopefully I won't experience any problems with it. I'll get back if it doesn't work as it should (which I cannot figure out why it wouldn't). Thanks for the help!