Introduction to ThinkPHP routing mechanism

Source: Internet
Author: User
: This article mainly introduces the ThinkPHP routing mechanism. if you are interested in the PHP Tutorial, refer to it. This example describes the ThinkPHP routing mechanism. We will share this with you for your reference. The details are as follows:

ThinkPHP supports URL routing. to enable routing, set ROUTER_ON to true. After the routing function is enabled, the system automatically performs routing Detection. if a route name that matches the current URL is found in the routing definition, route resolution and redirection are performed. The routing function must define the routing definition file, which is located under the configuration Directory of the project and named routes. php.
Definition format:

Return Array ('routename' => array ('Module name', 'Operation name', 'parameter define', 'additional parameters'), // regular routing );

For example, we have enabled the routing function and defined the following routing rule:

'Blog '=> array ('blog', 'index', 'Year, month, Day', 'userid = 1 & status = 1 ')

So we are executing

The code is as follows:

/AppName/blog/2007/9/15 "> http :// /AppName/blog/2007/9/15

The index operation of the Blog module will be executed, and the following parameters/2007/9/15/will be parsed by year/month/day in sequence, and the userId = 1 and status = 1 parameters are implicitly passed in.

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.