1

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?

tereško
  • 58,060
  • 25
  • 98
  • 150
metaforce
  • 1,337
  • 5
  • 17
  • 26

2 Answers2

8

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

'home' => 'site/index',

I hope that helps.

thaddeusmt
  • 15,410
  • 9
  • 67
  • 67
0
'urlManager'=>array(
        'urlFormat'=>'path',
             'useStrictParsing'=>true,
        'rules'=>array(
                          '' => 'site/index',
                            'Home'=>'site/index',

first one will show empty instead of home. second one will show Home instead of site/index

Jay kumar
  • 277
  • 2
  • 13