'Run Application from the desired location - yii2

This is my project structure

project1
    -assets
    -commands
    .
    .
    .
    modules
        -people
            -controllers
                -PeopleController.php
            -models
            -views
            People.php



    web
        -index.php

I'm deploying it to server. URL hit: https://11.11.11.11/project1/web/index.php/people/people/index

Where should I modify in server files, so that URL: https://11.11.11.11/people/people/index works for me? I don't want user to know the folder name where my codes are available.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sob sad