yiiyii-validation

Yii url rules for main page


'urlManager'=>array(
            'class'=>'application.components.UrlManager',
            'urlSuffix'=>'/',
            'baseUrl'=>'',
            'showScriptName'=>false,
            'urlFormat'=>'path',
            'rules'=>array(
                '<language:\w{2}>'   => 'page/index',
                ''   => 'page/index',
                '<language:\w{2}>/page/<alias:.*>' => 'pages/read',
            )

link "/en/page/index" works fine
links "/" and "/en" returns the error "Unable to resolve the request" page / index ".

what is wrong with the rules

'<language:\w{2}>' => 'page/index'
'' => 'page/index',  

?

UPD:

pagesController has an action:

public function actionRead($alias){

            //some php code...

            if($model==null)
            {
                throw new CHttpException(404,'page not found...');
            }else
            {
                $this->render('read',array('model'=>(object)$model));
            }

}

Solution

  • Your rules that don't work are redirecting to page/index, meaning that they're going to try and access PageController.php, and within that controller, they're going to try an access actionIndex. It doesn't sound like you have either a controller PageController.php, much less an actionIndex within that controller.

    You need to fix the targets of those rules to include valid controller/action combinations.