0

我定义了这条路线:

$route['search/(:any)/(:num)/(:num)/(:num)/(:num)'] = "home/results/$1/$2/$3/$4/$5";

和我在 results() 函数中的分页:

    $config['base_url'] = base_url().'/search/'.$data['keyword'].'/'.$data['1'].'/'.$data['2'].'/'.$data['3'].'/';
    $config['per_page'] = 10;
    $config['uri_segment']=6; 

它工作得很好,除了当我从任何下一页返回第一页时 - 找不到 url,因为当我在浏览器中输入时:

mysite.com/search/key/param1/param2/param3/0 (first page) -> works fine

但是当我想从以下位置转到第一页时:

mysite.com/search/key/param1/param2/param3/10 (second page) => 
mysite.com/search/key/param1/param2/param3/ (fiest page - without "0" index at the end, pagination doesn't add it at the end)

然后找不到网址

4

1 回答 1

0

您必须添加多条路线才能工作:

$route['search/(:any)/(:num)/(:num)/(:num)/(:num)'] = "home/results/$1/$2/$3/$4/$5";
$route['search/(:any)/(:num)/(:num)/(:num)'] = "home/results/$1/$2/$3/$4/0";
$route['search/(:any)/(:num)/(:num)'] = "home/results/$1/$2/$3/0/0";
...

我想你明白了

于 2012-08-23T12:07:32.080 回答