문제

I am new to yii. My urlmanager is not changing the get params...here is code of yiicode/protected/main.php

'urlManager'=>array(
        'urlFormat'=>'path',


                      'rules'=>array(

                            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

        ),
    ),

view code

$this->pageTitle=Yii::app()->name;
$params=array('city'=>'london');
$route='site/index';
$ur=$this->createUrl($route,$params);

html

<a href="<?php echo $ur;"?> >Click here to check London hotels</a> 

on clik it goes to url /yiicode/index.php/site/index?city=london instead of /yiicode/index.php/site/index/city/london

도움이 되었습니까?

해결책

You have to add rule like this.

'rules'=>array(
            'site/index/city/<city:.*?>'=>'site/index',

            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

        ),

다른 팁

add such rule: 'site/index/city/<city:.*?>'=>'site/index'

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top