Roshni
Roshni

Reputation: 11

how to load css in codeigniter?

My page is unable to load the CSS when I am trying to load the page with default controller like this: //localhost/mysite/

But when I am trying to load the page like this //localhost/mysite/index.php/site/index css the CSS is loaded perfectly, and I have to create both my css and image folders like this:

Path C:\wamp\www\tt\assets\css and all other application paths are in the root path of the tt like c:\wamp\www\tt\application.

Please give me solution as soon as possible.

Upvotes: 1

Views: 116

Answers (2)

Sachin Prasad
Sachin Prasad

Reputation: 5411

Create a .htaccess file in your tt folder. And place this to remove index.php from your url:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

And you should be able to access your file directly <?php echo base_url()."tt/assets/css/cssfilename.css" ?>

Upvotes: 1

Jitesh Tukadiya
Jitesh Tukadiya

Reputation: 1339

you should give read/write permissions to assets folder and you should user this script to link the css

<link rel="stylesheet" href="<?php echo base_url('assets/css/style.css');?>">

Upvotes: 1

Related Questions