我遇到了代码点火器路由的问题
我需要这样做:
method/:any = method/index_function
method/edit/:any = method/edit_function
我在路由配置文件中写道:
$route['method/:any'] = 'method/index';
$route['method/edit/:any'] = 'method/edit';
但不要作品。
有什么建议吗?
下定决心!
我更改了路由文件中的行顺序:
$route['method/edit/:any'] = 'method/edit';
$route['method/:any'] = 'method/index';
感谢Basheer Ahmed
路由将按照定义的顺序运行。较高的路线总是优先于较低的路线。代码点火器路由
$route['method/edit/(:any)'] = 'controller/edit';
$route['method/(:any)'] = 'controller/index';
如果我没有弄错,您的路由键不能与现有控制器同名,因为CodeIgniter将首先检查控制器,如果找到控制器,它将尝试调用该控制器中的方法。请尝试:
$route['m/:any'] = 'method/index';
$route['m/edit/:any'] = 'method/edit';
您基本上忘记了应用括号。Codeigniter路由真的很棒。以下是我如何在我的项目中实现同样目标的例子:
$route['listnote/stepone/(:any)']='listnote/listnote/loanInformation';