Codeigniter-类似Twitter的URI路由

Codeigniter-类似Twitter的URI路由,codeigniter,Codeigniter,假设我想要下面的URL方案,我通过设置下面的URI路由来实现它 现在,假设我希望我的URL在显示“状态”时如下所示 我如何将“jimbob123”和“908734efc”传递到我的方法中,以便检查和检索这个特定的记录?我尝试了以下方法,但似乎不起作用 $route['user/(:any)/status/(:any)'] = "user/plan/$1/$2"; 我假设你在哪里写的user/(:any)/status/(:any)你的意思是profile/(:any)/status/(:a

假设我想要下面的URL方案,我通过设置下面的URI路由来实现它

现在,假设我希望我的URL在显示“状态”时如下所示

我如何将“jimbob123”和“908734efc”传递到我的方法中,以便检查和检索这个特定的记录?我尝试了以下方法,但似乎不起作用

$route['user/(:any)/status/(:any)'] = "user/plan/$1/$2";

我假设你在哪里写的
user/(:any)/status/(:any)
你的意思是
profile/(:any)/status/(:any)

这可能是一个问题,也是一个问题:

路由将按照它们声明的顺序进行匹配。如果你是这样写的:

$route['profile'] = "profile/index";
$route['profile/(:any)'] = "profile/index/$1";
$route['profile/(:any)/status/(:any)'] = "user/plan/$1/$2";
它不起作用,因为“http://www.domain.com/profile/jimbob123/status/908734efc“匹配第二条路线

如果你交换第二行和第三行,你应该很好

$route['profile'] = "profile/index";
$route['profile/(:any)/status/(:any)'] = "user/plan/$1/$2";
$route['profile/(:any)'] = "profile/index/$1";

啊好的。。。你能看看下面的链接吗?在他的route.php文件中,第7行是什么意思?我假设第7行将带您进入一个用户配置文件页面,您可以在其中添加或编辑用户信息。我通常会通过两个函数来实现,因为它与两个操作相关,所以我不知道他为什么要将它映射到一个函数。请注意,第8行路由与第7行路由不匹配,这与您的情况不同:any将拾取任何字符集。
$route['profile'] = "profile/index";
$route['profile/(:any)/status/(:any)'] = "user/plan/$1/$2";
$route['profile/(:any)'] = "profile/index/$1";