好的,删除了我之前的问题并重新制定了新问题,否则没有人会理解,抱歉。所以这里留下的问题是:
所以我想重写一个单词的URL,该单词使用零,一和两个参数,但不能用3:
带有2个参数的原始网址:
index.php?r=site/page&view=exposities&tijd=nu
urlmanager rule:
'exposities_nu'=>array('site/page', 'defaultParams' => array('view' => 'exposities', 'tijd'=>'nu')),
结果:
/exposities_nu/
现在什么行不通:
包含3个参数的原始网址:
index.php?r=site/page&view=exposities&tijd=vestiging&locatie=1
urlmanager rule:
'knsm'=>array('site/page', 'defaultParams' => array('view' => 'exposities', 'tijd'=>'nu', 'locatie'=>'1')),
结果:
index.php?r=site/page&view=exposities&tijd=vestiging&locatie=1
有人为什么这个最后的网址没有缩短为/ knsm /?
答案 0 :(得分:0)
也许您没有在网址管理器中设置网址。见这个例子:
return array(
......
'components'=>array(
......
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'post/<id:\d+>/<title:.*?>'=>'post/view',
'posts/<tag:.*?>'=>'post/index',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
),
);
您还必须正确创建网址:
Yii::app()->createUrl('post/view', array(
'id'=>$this->id,
'title'=>$this->title,
));