Search code examples
phpyiiyii2yii-url-manager

How to create this urlManager rule?


First of all, excuse my low english.

Having the following action in the controller named webController:

public function actionPage($view = 'index')
{
  try {
    return $this->render('site/page/' . $view);
  } catch (InvalidParamException $e) {
    throw new HttpException(404);
  }
}

I need a rule to do the following:

localhost/cookies

equals

localhost/?r=web/page&view=cookiesyprivacidad

or

localhost/faq

equals

localhost/?r=web/page&view=preguntas

Something like this:

'rules'=>array(
   'cookies'=>'web/page'
)

But adding a fixed parameter.


Solution

  • You need this

    'urlManager' => array(
      'rules' => array(
        <view:(cookies|faq)>' => 'web/page'
      )
    )