strangeloops
strangeloops

Reputation: 1484

Codeigniter: unable to link the referencing css file

I am just starting out with Codeigniter. I have referenced the css file in the corresponding views file but it fails to link. This is the code I have used to reference the css file.

<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen"/>

I tested the css code by inserting it between & and it works. Just can't get the linking to work.

Upvotes: 5

Views: 8462

Answers (2)

Dane Calderon
Dane Calderon

Reputation: 81

(two years later)... For the RewriteRule in the .htaccess file, you want your path starting with your server's root, so for example, if you're using WAMP, and you have a folder at C:\wamp\www\my_site\my_new_app then your RewriteRule should say

RewriteRule ^(.*)$ /mysite/my_new_app/index.php/$1 [L]

Just throwing that out there for us CI newbs

Upvotes: 0

Matteo Riva
Matteo Riva

Reputation: 25060

I'm sorry, rewriting the whole answer as I remember what I had to do and which should fix your problem.

Check your .htaccess file in the top level directory, I added exceptions for js/css/images dirs otherwise they would have been rewritten:

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

Upvotes: 8

Related Questions