codeigniterpaginationroutes

Codeigniter pagination routing issue


I have configured a route in routes.php as:

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

And pagination configuration in controller as follows:

$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;

It is showing 404 error page while loading: www.example.com/job-history

It will work if manually add a zero like: www.example.com/job-history/0

How can I load www.example.com/job-history as the first page? What is wrong in my configuration?


Solution

  • You'll need a route for the single job-history segment as well.

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