I have 'urlFormat'=>'path' and 'showScriptName'=>false in the urlManager.
I have proxies/read as controller/action and article=>some_name as parameters.
Whenever I create a link such as:
$this->createUrl(‘proxies/read’, array(‘article’=>$name));
The result is an URL of the type:
proxies/read?article=socks5_proxy_list
I would like to dump the query parameter and reformat the URL to look like this:
controller/action/param_name/param_value
In this case that would be:
proxies/read/article/socks5_proxy_list
My current ‘rules’ look like this:
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/article/<article:\w+>'=>'<controller>/<action>/article/<article>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
But they don’t seem to be working.
Shortcut to make this work:
And leave the urlManager rules without your custom rule.
Another way:
In the above array, i just put the new rule in the beginning, to make sure that, that rule is applied whenever such a pattern is encountered. If you have other rules, then just make sure that this rule appears before a more general rule, that can match the pattern. Rule of thumb: more specific rule should appear before general rule.
create url in view:
Incase you don’t need any of the default “user-friendly url” rules, but only need path format urls, then you only need to specify
'urlFormat'=>'path'and leave the'rules'array empty or omitted all together.Read the URL Management guide in the definitive guide, if you haven’t already.