phpyiiyii-routing

Yii Framework - URL Manager and Rules for routing


I have these default route rules in my urlManager in Yii framework:

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
    ),
),

I have a SiteController.php for all the /site/ requests. What I need now is to redirect /home request to /site/index.

I've tried adding this array item:

'home' => '/site/index',
'/home' => 'site/index',

And none of them worked.

Can anyone solve this issue?


Solution

  • Just remove the extra '/' slashes. This worked for me when I tested it just now:

    'home' => 'site/index',
    

    I hope that helps.