0

I have a directory in the root of my codeigniter application called /css it contains the file style.css. When I link to the file using href="<?php echo base_url();?>css/styles.css" my css does not run, appears as html.

I have read on the net that I need to modify my .htaccess file in order to do this, many articles have explained how but the methods just have not worked for me.

How, using the htaccess code below, can I enable the reading of the following folders /images, /js, /css.

I am using codeigniters default htaccess code for removing index.php

<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>  
6
  • Well, uhm, im not really following you: this is the expected behaviour. If you link directly to a stylesheet you see the stylesheet. What else do you want it to do? Commented Oct 25, 2011 at 11:40
  • I can see the stylesheet but some reason codeigniter isn't reading it as css and adding html to the top of it. Commented Oct 25, 2011 at 11:42
  • you mean like: <html><head></head><body>#blockthing{bunchof:css;}</body></html> ? Commented Oct 25, 2011 at 11:44
  • Yes, and at the bottom it says div id="container"> <h1>An Error Was Encountered</h1> <p>The URI you submitted has disallowed characters.</p> </div> Commented Oct 25, 2011 at 11:58
  • Do you have a link to that... Because im not sure what you want htaccess to do? css code shouldnt "run" Commented Oct 25, 2011 at 12:32

1 Answer 1

1

Try this it's working.

  <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.