CodeIgniter Routing related issues

Source: Internet
Author: User
Tags codeigniter
CodeIgniter Routing problems
I'm not familiar with CodeIgniter. This is especially the way to route this piece. Now change to a system. Write the controller after the access always appears "Route_error" error;

For example, I wrote a login.php controller placed in the Controllers/admin directory, I directly access Www.abc.com/admin/login will appear "Route_error." Error.
If I add a line to route.php:
$route [' admin ']= "admin/login";
That's all you can do. But too much trouble, I can not write a controller to modify the route.php it?!

Here is my route.php file. Do not understand what the previous meaning, we help to see how to set up I can normally write my controller without affecting the previous use:

$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 Frame routing can use the name


Other settings can add your own defined routing rules:
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 ')); Would 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
  • 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.