Html::a()在yii2的超链接中通过干净的url传递多个参数,不会生成干净的url

Html::a()在yii2的超链接中通过干净的url传递多个参数,不会生成干净的url,yii2,clean-urls,yii-url-manager,Yii2,Clean Urls,Yii Url Manager,我正在尝试使用中提到的方法生成超链接 像这样 Html::a('<b>Register</b>', ['story/create', array('id' =>39,'usr'=>'11')], ['class' => 'profile-link']) 我已经启用了像yii2一样的干净url功能 'urlManager' => [ 'class' => 'yii\web\UrlManager',

我正在尝试使用中提到的方法生成超链接 像这样

 Html::a('<b>Register</b>', 
    ['story/create', array('id' =>39,'usr'=>'11')], 
    ['class' => 'profile-link'])
我已经启用了像yii2一样的干净url功能

  '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.
“urlManager”=>[
'class'=>'yii\web\UrlManager',
//禁用index.php
'showScriptName'=>false,
//禁用r=路由
“enablePrettyUrl”=>true,
'规则'=>数组(
“/”=>“/视图”,
'//' => '/',
'/' => '/',
),
],也是。

如何实现这一点?

使用generate
url
这样使用(请参阅更多):

在控制器中:

public function actionCreate($id, $usr)

和Yii2提供此参数。

动态创建Url

Html::a('<b>Register</b>', 
    ['story/create', 'id' =>39,'usr'=>'11'], 
    ['class' => 'profile-link'])

另一个有用的方法:

在应用程序中写入urlManager规则

'rules'=>array('/controller/action/<limit>/<offset>'=>'/controller/action/'),
'rules'=>数组('/controller/action/'=>'/controller/action/'),

可以在url controller/action/100/20中访问它仍在生成类似于story/create?1%5Bid%5D=39和1%5Busr%5D=1In
Html
中的set
['story/create','id'=>39,'usr'=>11'],
?它现在正在创建类似于reg/create/39?usr=1,我需要吗?我试过了,效果很好。看-还有我的
.htaccess
我不知道这像是create/39?usr=1,可能与Html::a()生成超链接有关
story/create/39/11
public function actionCreate($id, $usr)
Html::a('<b>Register</b>', 
    ['story/create', 'id' =>39,'usr'=>'11'], 
    ['class' => 'profile-link'])
'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
             '<controller:\w+>/<id:\d+>' => '<controller>/view',            
             '<controller:\w+>/<action:\w+>/<id:\d+>/<usr:\d+>' => '<controller>/<action>', 
        ],
    ],
story/create/39/11
'rules'=>array('/controller/action/<limit>/<offset>'=>'/controller/action/'),