Run Application from the desired location - yii2

Viewed 37
1 Answers

The answer varies depending on the type of server you use or the use of shared hosting
You can use this tutorial to configure the server.

To remove web and index.php Or ... :
Add the following code to the config/web.php file:

 use \yii\web\Request;
 $baseUrl = str_replace('/web', '', (new Request)->getBaseUrl());

 $config = [
     #code...
     'components' => [
          // ...
         'request' => [
               // ...
              'baseUrl' => $baseUrl,  // Add baseUrl
         ],

         // ...
         'urlManager' => [
             'baseUrl' => $baseUrl,  // Add baseUrl
             'enablePrettyUrl' => true,
             'showScriptName' => false,
             'enableStrictParsing' => false,
             'rules' => [
                 // ...
             ],
         ],
         // ...
     ],
 ]

Tutorial on this page can also help.

Related