How can I rewrite urls in Yii2

Published on Author Code Father

Need to add following rules code for urlManager in config/main.php(if advance template) or web.php.

[
    'components' => [
        'urlManager' => [
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'enableStrictParsing' => false,
            'rules' => [
                   'post/<id:\d+>-example' => 'post/index',
            ],
        ],
    ],
]

Comments

comments

Categories Yii

One Response to How can I rewrite urls in Yii2