用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3388|回复: 0
收起左侧

[Others] codeigniter路由问题

[复制链接]
发表于 2010-4-23 16:10:12 | 显示全部楼层 |阅读模式
对codeigniter不太熟悉.尤其路由这块.现在改一套系统.自己写的控制器后访问总是出现“route_error”错误;

比方说我写了个login.php控制器放在controllers/admin目录下,我直接访问www.abc.com/admin/login 就会出现“route_error.”错误。
如果我在route.php加上一行:
$route['admin']="admin/login";
这样就可以了。但是太麻烦了,我不可能每写一个控制器就去修改一下route.php吧?!

下面是我的route.php文件。看不懂以前是什么意思,大家帮忙看看怎么设置我才可以正常来写我的控制器而不影响以前的使用:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";

//name-of-school/class-of/firstname-lastinitial/photo-albums/album-name/upload/
$route['([a-zA-Z0-9\-_ ]+)/([a-zA-Z0-9\-_ ]+)/([a-zA-Z0-9\-_ ]+)/(video|photo)\-([a-zA-Z0-9\-_ ]+)/([a-zA-Z0-9\-_ ]+)/([a-zA-Z0-9\-_ ]+)(/([a-zA-Z0-9\-_ ]+))*'] = "user/$4_$5/$7/$8";

$route['([a-zA-Z0-9\-_]+)/school_admin/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(/([a-zA-Z0-9\-_]+))*'] = "school_admin/$3/$4$5";

$route['([a-zA-Z0-9\-_]+)/group_admin/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(/([a-zA-Z0-9\-_]+))*'] = "group_admin/$3/$4$5";


//name-of-school/class-of/firstname-lastinitial/games/game-name/
$route['([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(/([a-zA-Z0-9\-_]+))*'] = "user/$4/$5/$6";


//logout
$route['(logout|login|register)'] = "member/$1";

//404
$route['(games|video-albums|photo-albums|group|admin|groupadmin|yearbook|settings)(/.*)*'] = "error";

本版积分规则