Search code examples
urlyiiurl-rewritingyii-url-manager

change rules in yii URL manager for friendly URLs


I've got a controller that requires two parameters

 public function actionIndex($type = 'recent-jokes',$offset = 0)
 // rest of codes

I want the URL to be like this so it can get the params from the URL

something.com/items/type/offset

right now here is my Config in my main.php

 'rules'=>array(
    ''=>'items/index',
    '<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',
    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),

could you help me out here :)
thanks a lot for this awesome community


Solution

  •  'rules'=>array(
        'items/<type:\w+>/<offset:\w+>' => 'items/index',
        /* other rules */
      ),
    

    There you go.