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

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

问题描述

使用



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



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

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

它不会工作。我想它会使用



pages / view / del / $ 1



而不是我的crud-controller删除一个项目。

如下所示, $ route ['(:any)'] 会匹配任何网址,因此在全部接收路线之前放置其他自定义路线:

  $ route ['del /(:any)'] ='crud / del'; 
//根据需要的其他路由...
$ route ['(:any)'] ='pages / view / $ 1';


When using

$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

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

解决方案

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天全站免登陆