Reputation: 315
I am using Yii::app()->createAbsoluteUrl("sports", array('q' => 'football'))) this to print example.com/sports/football but it prints like this example.com/sports/q/football. How would we remove parameters name in this case "q" from url.
main main config file looks like this:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'search/<q>' => 'search/index',
'sports' => 'sports/index',
'sports/<q>' => 'sports/index',
),
),
Upvotes: 1
Views: 1113
Reputation: 5039
sports/<q:\w+> => 'sports/index
or
sports/<q:[a-z-0-9-]+> => 'sports/index
depending if you need hyphens between words
CreatUrl should possibly be
Yii::app()->createAbsoluteUrl('sports/index', array('q' => 'football'))
Upvotes: 1