Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 473
Fredefl Avatar asked Aug 09 '26 17:08

Fredefl


1 Answers

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.

like image 94
simnom Avatar answered Aug 12 '26 20:08

simnom