1

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 Answer 1

1

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]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks sherif salah... after using http://, it is giving proper URL in view-source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.