Fredefl
Fredefl

Reputation: 1381

Assets in codeigniter

I've just started using codeigniter and wanted to include some external css in my view. This is my directory structure:

application
   ....
system
   ....
assets
    css
        style.css

I'm linking the file using this html code: (Used example.com as an example, lol)

<link rel="Stylesheet" type="text/css" href="http://example.com/assets/css/style.css"/>

Here is my .htaccess file:

RewriteEngine on

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Now, my problem is that it returns an 404 error. Say if you need more info.

Thanks in advance!

Upvotes: 3

Views: 3544

Answers (1)

simnom
simnom

Reputation: 2620

I've found the CI .htaccess rules some what restrictive having to add all different folders required. I therefore use the following:

# 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]

Give that a bash and see how you get on.

Upvotes: 6

Related Questions