Remove controller and action from url yii

366 Views Asked by At

I want to hide controller and action name from url and only slug will show.E.g http://localhost/test-project/frontend/web/test-condition and "test-condition" is slug.I want to manage this from urlManager in my config/main.php

1

There are 1 best solutions below

1
Subhasis Bhowmik On BEST ANSWER
'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                ....
                '<slug:[a-zA-Z0-9_ -]+>-consult' => 'CONTROLLER NAME/ACTION',
            ),
        ],