Yii2 - Custom route with unlimited parameters

Hello,

I’m trying to achieve a link like this:


http://www.example.com/{{dynamic_link_here}}/{{dynamic_var_1}}/{{dynamic_var_2}}/{{dynamic_var_3}}/{{dynamic_var_4}}/etc

Basically, I need to construct an URL that may have unlimited parameters, or no parameters at all.

Currently I’m only able to achieve a unique variable, using the following url rule:




'urlManager' => [

            'class' => 'yii\web\UrlManager',

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => array(

                '<namespace:\w+>/?' => 'site/index',

            )

        ],



Any ideas?

There are two ways to achieve that:

[list=1][]Create a rule class for that purpose (Check this out)[]Create a rule that allows everything and parse the url in your controller (eg: ‘<namespace:*>’=>‘yourcontroller/youraction’)[/list]

Hope it helps.

I am not quite clear on how to implement "optional" URL parameters within the url manager in the same manner in previous Yii versions.

Example: <controller:\w+>/<action:\w+>/* OR <controller:\w+>/<action:\w+>?(/check/<check:+d>)? How would i convert these to yii 2.0.0?

It would be good if we could get some further enlightenment on this because i have a route i would like to use some optional parameters in but i just cannot get it, they shouldnt have removed the simplicity of optional parameters that Yii 1.1 had