为什么我的路由codeigniter没有去正确的动作控制器?

Here my route

$route['posts/(:any)'] = 'posts/get_show/$1';
$route['posts/(:any)/dosomething'] ='posts/get_dosomething/$1';

Controller

public function get_show($id)
public function get_dosomething($id)

With the link posts/1/dosomething, route always points to the action get_show, it never goes to get_dosomething

Any idea how to fix it ? Thanks

you must first route like this

$route['posts/(:any)/dosomething'] ='posts/get_dosomething/$1';
$route['posts/(:any)'] = 'posts/get_show/$1';

because posts/1/dosomething is always fallen under $route['posts/(:any)'] . change one of your routes condition