1

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.

Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
  • You could use pretty urls: https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#using-pretty-urls – schmauch Mar 25 '22 at 08:43

1 Answers1

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.

sob sad
  • 13
  • 3