CodeIgniter - 使用 $route['(:any)'] = 'pages/view/$1' 时如何使用其他控制器? [英] CodeIgniter - When using $route['(:any)'] = 'pages/view/$1' how to use other controllers?

查看:29
本文介绍了CodeIgniter - 使用 $route['(:any)'] = 'pages/view/$1' 时如何使用其他控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用时

$route['(:any)'] = 'pages/view/$1';

并且我想在我的路由中使用其他控制器,例如:

and I want to use other controllers in my routing for example:

$route['del/(:any)'] = 'crud/del';

这行不通.我想它会使用

it won't work. I guess it will use

pages/view/del/$1

删除项目时,而不是我的 crud-controller.我该如何解决这个问题?

and not my crud-controller when deleting an item. How can I solve this?

推荐答案

如所示,$route['(:any)'] 将匹配 any URL,所以将您的其他自定义路由放在全能"路由之前:

As indicated, $route['(:any)'] will match any URL, so place your other custom routes before the "catch-all" route:

$route['del/(:any)'] = 'crud/del';
// Other routes as needed...
$route['(:any)'] = 'pages/view/$1';

这篇关于CodeIgniter - 使用 $route['(:any)'] = 'pages/view/$1' 时如何使用其他控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆