1
votes

new at codeigniter, trying simple code to load bootstrap css files with base_url() function.tried some answers on stackoverflow,but issue not solved.

my view name is.... articles_list.php my controller name... user.php

i edit config.php as follow 'localhost/ci';

i edit autoload.php as follow i load url helper in autoload.php

articles_list.php (loading css in view file)

<link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/css/bootstrap.css') ?>" >

user.php(controller)

$this->load->helper('url');
    $this->load->view('public/articles_list');

when i run my view file, css is not loading, when i check view source it should give me both stylesheet url and link address as "localhost/ci/assets/css/bootstrap.css" but when i see view source it show <link href="localhost/ci/assets/css/bootstrap.css"> and when mouse over at link it shows me localhost/ci/localhost/ci/assets/css/bootstrap.css link address. please help me to solve this issue and help me to learn codeigniter. enter image description here

1

1 Answers

1
votes

Make sure you set the base_url right in application/config/config.php file:

$config['base_url'] = 'http://localhost/ci/';

And of course make sure to use the correct .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]