我主要担心的是我在这里失踪的地方。在我开始在网站上添加内容后,该路由完全适用于我测试的内容
$route['projects/view/([A-Za-z0-9])/task/([A-Za-z0-9])'] = 'Projects/view_project_task/$1/$2';
模型中的函数定义如下:
public function view_project_task($project_id, $project_task_id)
如果我访问它http://mydomain/projects/view_project_task/1/8工作正常,如果我尝试访问http://mydomain/projects/view/1/task/8,我会在某些链接上收到404错误,而其他链接也有效。
答案 0 :(得分:0)
如果您尝试在路线中使用回调?
$route['projects/(.+)'] = function ($params)
{
$return = explode('/', $params);
//here you need to count how many params has to know if your url
//is like 1/8 -> [0]=>view_project_task [1]=>1 [2]=>8
//or like 1/task/8 [0]=>view [1]=>1 [2]=>task [3]=>8
return 'projects/view_project_task/' . strlower($return[1]) . '/' . ( count($return > 3)) ? $return[3] : $return[2];
};