Codeigniter分页路由问题

时间:2013-04-12 09:01:25

标签: codeigniter pagination routes

我已在routes.php中配置了路由,

$route['job-history/(:num)'] = "customer/customer/jobhistory/$1";
控制器中的

和分页配置如下,

$this->load->library('pagination');
$config['per_page'] = 25;
$config['total_rows'] = 100;
$config['base_url'] = $this->config->item('base_url').'job-history';
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(3) : 0;

加载时显示404错误页面,

www.example.com/job-history

如果手动添加零,例如www.example.com/job-history/0。

,它将起作用

如何将www.example.com/job-history作为首页加载。在我的配置中有什么不对。请帮忙

2 个答案:

答案 0 :(得分:11)

您还需要一个单job-history段的路线。

$route['job-history/(:num)'] = 'customer/customer/jobhistory/$1';
$route['job-history'] = 'customer/customer/jobhistory';

答案 1 :(得分:2)

因为在route.php中,您只提到了在其后面有一个数字段的作业历史记录页面,而且只有页面作业历史记录没有这样的规则,它会被重定向到404。

添加

$route['job-history'] = 'customer/customer/jobhistory';

之前

$route['job-history/(:num)'] = 'customer/customer/jobhistory/$1';