【发布时间】:2012-01-10 13:02:50
【问题描述】:
我想要以下行为:
-
http://www.example.com/ 应转至:http://example.com/welcome
(通过在 routes.php 中设置 default_controller 完成)
- http://www.example.com/controllerName/functionName应该去 控制器名称,然后是它的函数 IF THE CONTROLLER EXISTS。
- 如果
controllerName不存在,它应该转到: specialController 和 specialFunction 与functionaName为 参数
例如。 http://www.example.com/greatProducts 应该变成
http://www.example.com/specialController/specialFunction/greatProducts 如果greatProducts 控制器不存在,(它可以是任何字符串,而不仅仅是greatProduct,大小写相同,即具有该名称的控制器不存在)
希望最好使用路由规则来实现这一点, 通过编辑库来更改 URI 段对我来说似乎不是一个好选择。
这行得通:
我通过在 core/Routes.php 中编辑 Routes.php 并添加类似的内容进行了尝试
`$segments = array("specialController","specialFunction",$segments[0]);
return $segments;`
如果发现控制器不存在。
【问题讨论】:
标签: php codeigniter