【问题标题】:Codeigniter pagination routing issueCodeigniter 分页路由问题
【发布时间】:2013-04-04 17:33:47
【问题描述】:

我在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 作为首页加载。我的困惑有什么问题。请帮忙

【问题讨论】:

  • @Cryode 是正确的。您可以尝试使用$route['job-history(/:num)?'] = 'customer/customer/jobhistory$1'; 将两条路线组合成一条路线,我没有测试,但请尝试一下。

标签: codeigniter pagination routes


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    添加

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

    之前

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

    【讨论】:

      猜你喜欢
      • 2013-01-16
      • 2011-09-16
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多