codeigniter路由有关问题

WBOY
Release: 2016-06-13 13:53:41
Original
787 people have browsed it

codeigniter路由问题
对codeigniter不太熟悉.尤其路由这块.现在改一套系统.自己写的控制器后访问总是出现“route_error”错误;

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

下面是我的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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template