user3721008
user3721008

Reputation: 103

Code-igniter href duplicate base url

<li><a href="<?php echo site_url('home'); ?>">Home</a></li>

that give to me localhost/farmex/localhost/farmex/home

and suppose to be localhost/farmex/home

Upvotes: 1

Views: 1205

Answers (2)

Shaiful Islam
Shaiful Islam

Reputation: 7134

base_url need to set to get proper link from site_url function.

At your application/config.php you need to set

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

Remember $config['index_page'] is also important.

If you set

  $config['index_page'] = 'index.php';

site_url('home') will produce http:/localhost/farmex/index.php/home

$config['index_page'] = 'index.php?'; will produce http:/localhost/farmex/index.php?/home which is needed sometimes.like if you don't want to use .htaccess file.

Upvotes: 0

mrdragon
mrdragon

Reputation: 247

in routes.php you can set $route['default_controller'] = 'home'; and change your code to <li><a href="<?php echo base_url(); ?>">Home</a></li> Hope this help! ^^

Upvotes: 1

Related Questions