0

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

4
  • why do you want to use a htaccess file? It would be easier to set the DocumentRoot property in the VirtualHost Entry inside the configuration. Commented Aug 10, 2015 at 14:25
  • i think the .htaccess config is better cos all routing is correct Commented Aug 11, 2015 at 7:56
  • the problem in this case: your public directory (web) is not your DocumentRoot directory and so you can address files deeper in your filesystem than usualy wanted. But I will post you a solution with .htaccess in a few minutes Commented Aug 11, 2015 at 14:07
  • please specify which part of the top url is projectname, which is controller and which is the action. ty Commented Aug 11, 2015 at 19:23

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.