title: Yii2 backend url manager rules for module
body: <p>I have created a module in Yii2 using Gii code generator. My new generated module location is</p>
  
  <p>backend/modules/cms</p>
  
  <p>cms is new generated module name.</p>
  
  <p>backend/config/main.php after setting module configuration looks as following</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>return [
  
      'id' =&gt; 'app-backend',
      'basePath' =&gt; dirname(__DIR__),
      'controllerNamespace' =&gt; 'backend\controllers',
      'bootstrap' =&gt; ['log'],
      'modules' =&gt; [
          'gii' =&gt; [
              'class' =&gt; 'yii\gii\Module', //adding gii module
              'allowedIPs' =&gt; ['127.0.0.1', '::1']  //allowing ip's 
          ],
          'cms' =&gt; [
              'class' =&gt; 'backend\modules\cms\Cms',
      ],
      ],
      'components' =&gt; [
          'user' =&gt; [
              'identityClass' =&gt; 'common\models\User',
              '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; 'site/error',
          ],
          'urlManager' =&gt; [
              'class' =&gt; 'yii\web\UrlManager',
              'enablePrettyUrl' =&gt; true,
              'showScriptName' =&gt; false,
              'rules' =&gt; [
                  '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\w+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',
                  '&lt;controller:\w+&gt;/&lt;action:\w+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',
                                  
                  '&lt;module:\w+&gt;/&lt;controller:\w+&gt;/&lt;action:\w+&gt;' =&gt; '&lt;module&gt;/&lt;controller&gt;/&lt;action&gt;',
                  '&lt;module:\w+&gt;&lt;controller:\w+&gt;/&lt;action:update|delete&gt;/&lt;id:\d+&gt;' =&gt; '&lt;module&gt;/&lt;controller&gt;/&lt;action&gt;',
              ]
          ],
          'assetManager' =&gt; [
              'bundles' =&gt; [
                  'yii\web\JqueryAsset' =&gt; [
                      'js' =&gt; []
              ],
          ],
      ],
      ],
      'params' =&gt; $params,
  ];</code></pre>
  </div>
  </div>
  </p>
  
  <p>behaviors function in controller looks as after setting access rules</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public function behaviors() {
          return [
   'access' =&gt; [
                  'class' =&gt; AccessControl::className(),
                  'rules' =&gt; [
                      [
                          'actions' =&gt; ['login', 'error'],
                          'allow' =&gt; true,
                      ],
                      [
                          'actions' =&gt; ['logout', 'index', 'create', 'update', 'delete'],
                          'allow' =&gt; true,
                          'roles' =&gt; ['@'],
                  ],
              ],
              ],
              'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
                  'delete' =&gt; ['post'],
              ],
                  ],
          ];
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Only index action of my controller is accessible. when i access any other action in controller url changes but shows index action contents.</p>
  
  <p>How can i access all actions in controller?</p>
  
  <p>It will be appreciable if someone help me resolving this issue.
  <strong>my controller</strong>
      
  
  <pre><code>namespace backend\modules\cms\controllers;
  
  use Yii;
  use yii\filters\AccessControl;
  use backend\modules\cms\models\Pages;
  use backend\modules\cms\models\PagesSearch;
  use yii\web\Controller;
  use yii\web\NotFoundHttpException;
  use yii\filters\VerbFilter;
  
  /**
   * PagesController implements the CRUD actions for Pages model.
   */
  class PagesController 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', 'create', 'update', 'delete'],
                      'allow' =&gt; true,
                      'roles' =&gt; ['@'],                        
              ],
              ],
              ],
              'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
  //                'delete' =&gt; ['post'],
              ],
                  ],
          ];
      }
  
      /**
       * Lists all Pages models.
       * @return mixed
       */
      public function actionIndex()
      {
  
          $searchModel = new PagesSearch();
          $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;post());
  
          return $this-&gt;render('index', [
              'searchModel' =&gt; $searchModel,
              'dataProvider' =&gt; $dataProvider,
          ]);
      }
  
      /**
       * Displays a single Pages model.
       * @param integer $id
       * @return mixed
       */
      public function actionView($id)
      {
          return $this-&gt;render('view', [
              'model' =&gt; $this-&gt;findModel($id),
          ]);
      }
  
      /**
       * Creates a new Pages model.
       * If creation is successful, the browser will be redirected to the 'view' page.
       * @return mixed
       */
      public function actionCreate()
      {
          echo "here";
          exit;
          $model = new Pages();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
              return $this-&gt;redirect(['index']);
          } else {
  
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
              ]);
          }
      }
  
      /**
       * Updates an existing Pages model.
       * If update is successful, the browser will be redirected to the 'view' page.
       * @param integer $id
       * @return mixed
       */
      public function actionUpdate($id)
      {
          $model = $this-&gt;findModel($id);
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('update', [
                  'model' =&gt; $model,
              ]);
          }
      }
  
      /**
       * Deletes an existing Pages model.
       * If deletion is successful, the browser will be redirected to the 'index' page.
       * @param integer $id
       * @return mixed
       */
      public function actionDelete($id)
      {
          $this-&gt;findModel($id)-&gt;delete();
  
          return $this-&gt;redirect(['index']);
      }
  
      /**
       * Finds the Pages model based on its primary key value.
       * If the model is not found, a 404 HTTP exception will be thrown.
       * @param integer $id
       * @return Pages the loaded model
       * @throws NotFoundHttpException if the model cannot be found
       */
      protected function findModel($id)
      {
          if (($model = Pages::findOne($id)) !== null) {
              return $model;
          } else {
              throw new NotFoundHttpException('The requested page does not    exist.');
          }
      }
  }
  </code></pre>
  
  <p>I am using Url as follows:
  <a href="http://localhost/yii2-demo/backend/cms/pages/index" rel="nofollow">http://localhost/yii2-demo/backend/cms/pages/index</a></p>
  
  <p><a href="http://localhost/yii2-demo/backend/cms/pages/create" rel="nofollow">http://localhost/yii2-demo/backend/cms/pages/create</a></p>