我想获取如下 URL:
http://domain.com/post/1/some-titles-here
但我得到:
http://domain.com/post/1?title=some-titles-here
我正在使用这个配置:
'urlFormat' => 'path',
...
//'post/<id:\d+>/<title>' => 'post/view/',
'post/<id:\d+>/<title:\w+>' => 'post/view/',
'post/<id:\d+>' => 'post/view/',
...
然后获取我正在执行的 URL:
Yii::app()->createAbsoluteUrl('post/view', array('id' => $this->id,'title' => $this->title));
我在这里遵循第三条规则: http ://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-named-parameters