title: Yii2: How do I fix 404 error when changing default controller on advanced template?
body: <p>I have changed my <code>$defaultRoute</code> on my config which looks like this. This is according to my default controller <code>AdminController</code>? I am getting 404 Error</p>
  
  <p><strong>main-local.php</strong></p>
  
  <pre><code>&lt;?php
  $config = [
  'defaultRoute' =&gt; 'admin/index',
  'components' =&gt; [
      'request' =&gt; [
          // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
          'cookieValidationKey' =&gt; 'b0pQ7nOuVjCprrOGrTarC-ErVMHUWQbb',
      ],
    ],
  ];
  if (!YII_ENV_TEST) {
  // configuration adjustments for 'dev' environment
  $config['bootstrap'][] = 'debug';
  $config['modules']['debug'] = 'yii\debug\Module';
  
  $config['bootstrap'][] = 'gii';
  $config['modules']['gii'] = 'yii\gii\Module';
  }
  
  return $config;
  </code></pre>
  
  <p>I am testing my app on localhost but I still have my main config with the default root.</p>
  
  <p><strong>main.php</strong></p>
  
  <pre><code>&lt;?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' =&gt; 'app-backend',
  'basePath' =&gt; dirname(__DIR__),
  'controllerNamespace' =&gt; 'backend\controllers',
  'bootstrap' =&gt; ['log'],
  'defaultRoute' =&gt; 'admin/index',
  'modules' =&gt; [],
  'components' =&gt; [
      'user' =&gt; [
          'identityClass' =&gt; 'backend\models\Admin',
          'enableAutoLogin' =&gt; true,
      ],
      'log' =&gt; [
          'traceLevel' =&gt; YII_DEBUG ? 3 : 0,
          'targets' =&gt; [
              [
                  'class' =&gt; 'yii\log\FileTarget',
                  'levels' =&gt; ['error', 'warning'],
              ],
          ],
      ],
      'errorHandler' =&gt; [
          'errorAction' =&gt; 'admin/error',
      ],
  ],
  'params' =&gt; $params,
  ];
  </code></pre>
  
  <p>My <code>.htaccess</code> has the following code:</p>
  
  <pre><code>Options +FollowSymLinks
  IndexIgnore */*
  RewriteEngine on
  
  # if request begins with /admin remove admin and ad /backend/web/
  RewriteCond %{REQUEST_URI} ^/admin
  RewriteRule ^admin\/?(.*) /backend/web/$1
  
  # other requests add /frontend/web/$1
  RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin)
  RewriteRule (.*) /frontend/web/$1
  
  # if frontend request 
  RewriteCond %{REQUEST_URI} ^/frontend/web
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /frontend/web/index.php 
  
  # if backend request
  RewriteCond %{REQUEST_URI} ^/backend/web
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /backend/web/index.php
  </code></pre>
  
  <p>Also here is my <code>AdminController</code> code:</p>
  
  <pre><code>&lt;?php
  namespace backend\controllers;
  use Yii;
  use yii\filters\AccessControl;
  use yii\web\Controller;
  use backend\models\LoginForm;
  use yii\filters\VerbFilter;
   class AdminController extends Controller
    {
     public function behaviors()
    {
      return [
          'access' =&gt; [
              'class' =&gt; AccessControl::className(),
              'rules' =&gt; [
                  [
                      'actions' =&gt; ['login', 'error'],
                      'allow' =&gt; true,
                  ],
                  [
                      'actions' =&gt; ['logout', 'index'],
                      'allow' =&gt; true,
                      'roles' =&gt; ['@'],
                  ],
              ],
          ],
          'verbs' =&gt; [
              'class' =&gt; VerbFilter::className(),
              'actions' =&gt; [
                  'logout' =&gt; ['post'],
              ],
          ],
      ];
  }
  
  /**
   * @inheritdoc
   */
  public function actions()
  {
      return [
          'error' =&gt; [
              'class' =&gt; 'yii\web\ErrorAction',
          ],
      ];
  }
  
  public function actionIndex()
  {
      return $this-&gt;render('index');
  }
  
  public function actionLogin()
  {
      if (!\Yii::$app-&gt;user-&gt;isGuest) {
          return $this-&gt;goHome();
      }
  
      $model = new LoginForm();
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;login()) {
          return $this-&gt;goBack();
      } else {
          return $this-&gt;render('login', [
              'model' =&gt; $model,
          ]);
      }
  }
  
  public function actionLogout()
  {
      Yii::$app-&gt;user-&gt;logout();
  
      return $this-&gt;goHome();
  }
  }
  </code></pre>
  
  <p>Am I inserting the <code>'defaultRoute' =&gt; 'myController/myAction',</code> in the wrong file. I do not want to do it on the framework code itself so I would really appreciate your assistance.</p>