Codeigniter routing is not familiar with codeigniter. especially for routing. now we need to change the system. the "route_error" error always occurs when accessing the controller written by myself. for example, I wrote a login. the php controller is stored in the controllersadmin Directory. I directly access www. abc. "route_error. "error. If I have problems with routing in route codeigniter
I am not familiar with codeigniter, especially routing. now I want to change the system. after I write my own controller, there will always be a "route_error" error during access;
For example, if I write a login. php controller and put it in the controllers/admin directory, the "route_error." error will occur when I directly access www.abc.com/admin/login.
If I add a line to route. php:
$ Route ['admin'] = "admin/login ";
In this way, you can. But it's too troublesome. I can't modify route. php every time I write a controller, right ?!
The following is my route. php file. I don't understand what I used to mean. let's take a look at how to set it so that I can write my controller normally without affecting the previous usage:
$ 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 ";
------ Solution --------------------
Www.abc.com/index.php/admin/login
------ Solution --------------------
Queryphp framework routing can be named
You can add custom routing rules for other settings:
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