backend shows the frontend pages

Hi everyone, Our backend dev is having quite an issue because the backend shows the files of the frontend. and I can’t answer him because I don’t know why it’s doing that.

Here’s the appasset of the backend.


<?php


namespace backend\assets;


use yii\web\AssetBundle;


/**

* Main backend application asset bundle.

*/

class AppAsset extends AssetBundle

{

  public $basePath = '@webroot';

  public $baseUrl = '@web';

  public $css = [

      'css/site.css',

  ];

  public $js = [

      'js/main.js',

  ];

  public $depends = [

      'yii\web\YiiAsset',

      'yii\bootstrap\BootstrapAsset',

  ];

}

Here’s the main.php file located on the backend/config/ folder


<?php

$params = array_merge(

   require(__DIR__ . '/../../common/config/params.php'),

   require(__DIR__ . '/../../common/config/params-local.php'),

   require(__DIR__ . '/params.php'),

   require(__DIR__ . '/params-local.php')

);


return [

   'id' => 'app-backend',

   'basePath' => dirname(__DIR__),

   'controllerNamespace' => 'backend\controllers',

   'bootstrap' => ['log'],

   'modules' => [],

   'components' => [

       'user' => [

           'identityClass' => 'common\models\User',

           'enableAutoLogin' => true,

       ],

       'log' => [

           'traceLevel' => YII_DEBUG ? 3 : 0,

           'targets' => [

               [

                   'class' => 'yii\log\FileTarget',

                   'levels' => ['error', 'warning'],

               ],

           ],

       ],

       'errorHandler' => [

           'errorAction' => 'site/error',

       ],

       'authManager' => [

                          'class' => 'yii\rbac\DbManager',

                          'defaultRoles' => ['guest'],

         ],

       /*

       'urlManager' => [

           'enablePrettyUrl' => true,

           'showScriptName' => false,

           'rules' => [

           ],

       ],

       */

   ],

   'params' => $params,

];

can you please let me know your thoughts. I’m new to Yii2 and can’t find similar questions here.

Hi

I think you gave [color="#008800"][size=“2”]‘basePath’[/size][/color] [color="#666600"][size=“2”]=>[/size][/color][size=“2”] dirname[/size][color="#666600"]size=“2”, same for both frontend and backend… Please check that… it should be different then only it will redirect to correct page…[/size][/color]

[color="#666600"] [/color]

[color="#666600"][size="2"]I mean www.test.com/backend or mostly www.test.com/admin[/size][/color]

[color="#666600"][size="2"]and for frontend www.test.com[/size][/color]

[color="#666600"] [/color]

[color="#666600"][size="2"]Please check and revert[/size][/color]