我正在使用Yii :: app() - > createAbsoluteUrl(“sports”,array('q'=>'football')))这打印example.com/sports/football但它打印得像这样example.com/sports/q/football。我们如何从url中删除参数名称“q”。
主要主配置文件如下所示:
'urlManager'=>阵列(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'search/<q>' => 'search/index',
'sports' => 'sports/index',
'sports/<q>' => 'sports/index',
),
),
答案 0 :(得分:1)
sports/<q:\w+> => 'sports/index
或
sports/<q:[a-z-0-9-]+> => 'sports/index
取决于单词之间是否需要连字符
CreatUrl应该是
Yii::app()->createAbsoluteUrl('sports/index', array('q' => 'football'))