Create Pretty Url in Yii2 Console

Hi,

Please help me. I’m dealing with the problem of creating the pretty url in console app.

Here is my config in console.php :


'urlManager' => [

        'enablePrettyUrl' => true,

        'scriptUrl' => 'https://example.com',

        'rules' => [

            'api/unsubscribe/<param:\w+>' => 'api/web/unsubscribe'

        ]

    ],

But when I tried to create a pretty url in console using this line of code


Url::to([

        "api/web/unsubscribe",

        'param' => base64_encode(serialize($params))

    ]);

It creates a url like example.com/api/web/unsubscribe?param=aTo4NjAwOw%3D%3D

Any solutions to create a url like example.com/api/unsubscribe/aTo4NjAwOw%3D%3D

That’s because you have = signs (%3D%3D) in your hash so it doesn’t match \w+