2013-10-21 49 views
0

您好我如何添加可选参数上的代码点火器的PHP路由可选CodeIgniter的路由参数使用动态控制器

$route['api/v1/(:any)'] = "$1/index";

$route['api/v1/(:any)/(:any)'] = "$1/index/$2";

例如的网址:

app.domain。 com/api/v1 /用户拨打电话$users->index()

app.domain.com/api/v1/users/1 call $users->index(1)

我需要TGE路线是动态的$route['api/v1/(:any)']

回答

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

感谢