Codeigniter routing-php Tutorial

Source: Internet
Author: User
Tags codeigniter
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.