您好如何在代码点火器php上添加可选参数以进行路由
$route['api/v1/(:any)'] = "$1/index";
$route['api/v1/(:any)/(:any)'] = "$1/index/$2";
例如网址:
app.domain.com/api/v1/users致电$users->index()
app.domain.com/api/v1/users/1 call $users->index(1)
我需要tge route是动态$route['api/v1/(:any)']
答案 0 :(得分:0)
我需要“用户”才能动态。我已经创建了一个路线,它对我有用,你可以检查一下这是否是最佳方式。
$route['api/v1/(:any)/([a-z 0-9~%.:@_\-]+)/(:any)'] = "$1/index/$2/$3";
$route['api/v1/(:any)/(:num)'] = "$1/index/$2";
$route['api/v1/(:any)'] = "$1/index";
由于