如何在Codeigniter中创建用于分页的动态网址?

时间:2019-04-12 12:49:33

标签: php codeigniter routes codeigniter-3

我正在尝试在Codeigniter中创建动态URL。我的关注网址运行正常

  

http://127.0.0.1/Mytredin_codesup/tags/user-interface

URL中的tags是静态值,而user-interface是动态值。但是当我单击“分页的下一步”按钮时,URL如下

  

http://127.0.0.1/Mytredin_codesup/tags/user-interface/1

并给出404 pages not found error

我为此所做的尝试

$route['tags/(:num)'] = 'tags/index/$1';
$route['tags/(:any)'] = 'tags/view/$1';

1 个答案:

答案 0 :(得分:2)

这应该有效,

$route['tags/(:any)'] = 'tags/index/$1';
$route['tags/(:any)'] = 'tags/view/$1';
$route['tags/(:any)/(:num)'] = 'tags/index/$1/$2';
$route['tags/(:any)/(:num)'] = 'tags/view/$1/$2';

和方法参数应具有

public function index($type, $id='')
public function view($type, $id='')

否则请确保,这将引发错误。

您在$1不接受的关键路线中添加了CI