代码点火器href重复基本网址

时间:2015-12-17 07:47:53

标签: codeigniter

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

给我localhost/farmex/localhost/farmex/home

并假设为localhost/farmex/home

2 个答案:

答案 0 :(得分:1)

在routes.php中

,您可以设置$route['default_controller'] = 'home';并将代码更改为 <li><a href="<?php echo base_url(); ?>">Home</a></li> 希望这有帮助! ^^

答案 1 :(得分:0)

base_url需要设置为从site_url函数获取正确的链接。

在您的application / config.php中,您需要设置

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

记住$config['index_page']也很重要。

如果您设置

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

site_url('home')将生成http:/localhost/farmex/index.php/home

如果你不想使用.htaccess文件,那么

$config['index_page'] = 'index.php?';会生成有时需要的http:/localhost/farmex/index.php?/home