Codeigniter default_controlller和分页

时间:2018-08-14 08:56:17

标签: codeigniter

我进入任何页面都会得到404页

Routes.php

$route['default_controller'] = "home";    
$route['default_controller/page/(:any)'] = 'home/$1';

控制器(home.php)

public function index($ppage=1)
    {
$this->load->library('pagination');
            $config['use_page_numbers'] = TRUE;
            $config['uri_segment'] = 2;

            $config['num_links'] = 5;
            $config['base_url'] = 'http://www.test.com/page/';

            $config['first_url'] = 'http://www.test.com/page/1';

            $this->pagination->initialize($config);
}

当我转到URL http://www.test.com/page/1http://www.test.com/page/2时,找不到404。这行我哪里出错了?

$route['default_controller/page/(:any)'] = 'home/$1';

1 个答案:

答案 0 :(得分:0)

默认控制器不是变量:

$route['home/page/(:any)'] = 'home/$1';

或者如果不起作用:

$route['page/(:any)'] = 'home/$1';

有点奇怪的方法imo。