Resolution of YII Framework URL

Source: Internet
Author: User
Tags filter array access yii
First of all, if you do not have urlmanager in the config/main.php, then the process is as follows (from Yii official website) The user sent the access URL http://www.example.com/index.php?r=post/show &id=1 request, the WEB server handles the request by executing the portal script index.php. The portal script creates an application instance and executes it. The application obtains detailed information about the user request from an application component called request. The Controller and action of the request are determined with the help of an application component called Urlmanager. In this example, the controller is post, which represents the Postcontroller class; The action is show and its actual meaning is determined by the controller. The application creates an instance of the requested controller to further process the user request. The controller determines that action show points to a method named Actionshow in the controller class. It then creates and holds the filter associated with the action (for example, access control, benchmark). If the filter allows, the action is executed. Action reads a Post model with ID 1 from the database. The action renders a view named show through the Post model. The view reads and displays the properties of the Post model. The view executes some small objects. The render result of the view is inserted into a layout. The action completes the view rendering and renders it to the user. But if you have configured Urlmanager as follows: ' Urlmanager ' =>array (            ' urlformat ' => ' path '),             ' rules ' =>array (                ' < Controller:\w+>/<id:\d+> ' => ' <controller>/index ',               & nbsp ' <controller:\w+>/<action:\w+> ' => ' <controller>/<actioN> ',                 ' <controller:\w+>/<action:\w+>/<id:\d+ > ' => ' <controller>/<action> ',            ,  ,      , Then direct access to http://www.example.com/index.php?r=post/show&id=1 is unlikely to get the result of the show action. First of all, this request will be given to Defaultcontroller's indexaction, Defaultcontroller in main.php, if Defaultcontroller is not Postcontroler, You might be confused. If it happens, it returns the contents of the indexaction, not the showaction. In fact, to access this is also very simple, http://www.example.com/index.php/post/show?id=1 on the line because Urlmanager has been set to follow <controller>/<action > in the form of  

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.