application/config/routes.php

Source: Internet
Author: User

URI Routing

This file lets you remap URI requests to a specified controller function

In general, there is a "one-to" relationship between the URL string and the Controller class/method it corresponds to. The segments in the URL typically follow the following pattern:

Example.com/class/method/id/

However, in some instances, you may want to remap this relationship to invoke a different class/method instead of a URL corresponding to the class/method

Please see the User Guide for complete information:

Https://codeigniter.com/user_guide/general/routing.html

Reserved routes

There are three reserved routes:

$route [' default_controller '] = ' welcome ';

If the URI does not contain any data (such as Access www.codeigniter.com), this route determines which controller class should be loaded.

$route [' 404_override '] = ' errors/page_missing ';

If the parameters provided in the URL do not match any legitimate route, this route tells the router which controller/method to use

$route [' translate_uri_dashes '] = FALSE;

Specifically, this is not a route, but it allows you to automatically route controllers and method names that contain dashes "-", '-' not a valid class or method name character, so it needs to be translated

When you set this option to true, it will displace all the dashes in the controller segment and method segment, such as Access My-controller/index will be converted to My_controller/index by the router.

If the URI contains News/create, the Create method of the news controller is called
$route [' news/create '] = ' news/create ';
If the first paragraph of the URI is news and the second paragraph is any character, then the view method of the news controller is called, and any character of the second paragraph is passed as an argument to it
$route [' news/(: any) '] = ' news/view/$1 ';
$route [' news '] = ' news ';

If you access www.codeigniter/index.php/a, you will access the view method of the pages controller and pass in parameter a
$route [' (: Any) '] = ' pages/view/$1 ';
When accessing www.codeigniter.com, the view method of the pages controller is accessed
$route [' default_controller '] = ' pages/view ';

application/config/routes.php

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.