简体   繁体   中英

Yii & Yii2: how to configure routing on a single method with a variable number of arguments?

I decided to move the logic with YII on Yii2 and a problem with the routing entry.

//yii1
'image/<id:\d+>*'   => array('image/get'),

But it doesn't work on YII2

//yii2 
'image/<id:\d+>*'   => 'image/get',

How to write the route to get function takes a variable number of arguments?

Try

'image'   => 'image/get',

And in the ImageController get the params the normal way

$id = \Yii::$app->request->post('id');

I have defined

'my-account' => 'my-account/index',

The link /my-account?id=5&foo=bar works just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM