对codeigniter不太熟悉.尤其路由这块.现在改一套系统.自己写的控制器后访问总是出现“route_error”错误;
如果我在route.php加上一行:
$route[‘admin’]=”admin/login”;
这样就可以了。但是太麻烦了,我不可能每写一个控制器就去修改一下route.php吧?!
$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”;
——解决方案——————–
www.abc.com/index.php/admin/login
——解决方案——————–
queryphp 框架路由可以使用名字
其它设置 可以添加自己定义的路由规则:
C(“router”)->ruleMaps(‘logout’,’/logout’, array(‘controller’ => ‘auth’, ‘action’ => ‘logout’));
C(“router”)->ruleMaps(‘signup’,’/signup’, array(‘controller’ => ‘auth’, ‘action’ => ‘signup’));
C(“router”)->ruleMaps(‘profile’,’/profile/:action’, array(‘controller’ => ‘profile’)); // will call controller “Profile” with dynamic method “:action()”
C(“router”)->ruleMaps(‘users’,’/users/:id’, array(‘controller’ => ‘users’), array(‘id’ => ‘[\d]{1,8}’)); // define filters for the url parameters
http://code.google.com/p/queryphp/downloads/list