Search code examples
codeigniterbase-url

Codeigniter: error in base_url


i have one problem with function base_url() in my codeigniter.

I'm configure the condeigniter to:

$config['base_url'] = 'sistema_clientes/';

$config['index_page'] = '';

and autoload to:

$autoload['helper'] = array('url');

It's ok, but when i'm try to use base_url('clientes') in my pages, the link repeat.

example, i wanna this : localhost/sistema_clientes/example.

<li><a href="<?= base_url('example'); ?>">Example</a></li>

in my url, the link go to: http://localhost/sistema_clientes/sistema_clientes/clientes

but i wanna this: http://localhost/sistema_clientes/clientes

i don't wanna the base_url() repeat the sistema_clientes, please help me.

what i can do to repear this?

Thanks.


Solution

  • Set your base_url like below:

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

    Because setting $config['base_url'] = 'sistema_clientes/'; makes sense that you are going to sistema_clientes controller so base_url becomeshttp://localhost/sistema_clientes/sistema_clientes.