Configuring URL rules
The Yii URL router is quite powerful and does two main tasks: it resolves URLs into internal routes and creates URLs from these routes. Router rules description is scattered over the official Yii guide and API docs. Let's try to understand how to configure application rules by example.
Getting ready
Create a fresh Yii application using
yiic webappas described in the official guide (http://www.yiiframework.com/doc/guide/) and find yourprotected/config/main.phpfile. It should contain the following:// application components 'components'=>array( … // uncomment the following to enable URLs in path-format 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ...