I am trying to generate a hyper link by the method mentioned in http://www.yiiframework.com/doc-2.0/guide-helper-html.html#hyperlinks like this
Html::a('<b>Register</b>',
['story/create', array('id' =>39,'usr'=>'11')],
['class' => 'profile-link'])
I want to get url like story/create/id/39/usr/11
But it is generating as
story/create?1%5Bid%5D=39&1%5Busr%5D=1
I have enabled the clean url functionality of yii2 like
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
], also.
How this can be achieved?
Another useful method :
Write in urlManager rules in your
Can be accessed in url controller/action/100/20
With generate
url
use like that (see more http://www.yiiframework.com/doc-2.0/guide-helper-url.html):In urlManager input new rule:
Output url will be like that:
And in controller:
And Yii2 provide this parameter.
create Url Dynamically
In urlManager config rules :
Output url will be like that: