Mohsen
Mohsen

Reputation: 1422

clean URL & URL rewrite with .htaccess in yii2

how make this url simpler http://localhost/yii-application/frontend/web/site/booking like http://localhost/controller/action in yii2 ?

http://localhost/yii-application/frontend/web/site/booking

i need simpler like :

http://localhost/yii-application/controller/action

how i can handle this with .htaccess

Upvotes: 0

Views: 191

Answers (1)

Mohsen
Mohsen

Reputation: 1422

By put this url manger :

    'urlManager' => [
        'class' => 'yii\web\UrlManager',
        // Disable index.php
        'showScriptName' => false,
        // Disable r= routes
        'enablePrettyUrl' => true,
        'rules' => [
            '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

        ] ]

you will achieve this

 http://localhost/yii-application/controller/action

Upvotes: 0

Related Questions