$defaultAction is not working

Hi guys. Used google many times, but cant find the answer. Trying to make defaultAction working.

Have 2 controllers. SiteController (this is main) and TourController. When i trying to call /tour, it makes 404 error. I thought the problem was in my TourController. I pasted $defaultAction in SiteController to check how it works. And it works! So what’s the problem? Help please!

TourController has a variable:


public $defaultAction = 'all';

This is my TourController:


namespace app\controllers;


use Yii;

use yii\web\Controller;

use app\models\Tournament;


class TourController extends Controller {

    

    public $defaultAction = 'all';

    

    public function actionAll()

    {

        $something = 'Tournament is here';

        

        $array = Tournament::getAll();

        

        return $this->render('all',['somethingView'=>$something, 'arrayView'=>$array]); 


    }

    

    public function actionSingle($id) 

    {

        $stour = Tournament::getOne($id);

        if (!empty($stour)){

            return $this->render('single',['stour'=>$stour]);

        }

        throw new \yii\web\NotFoundHttpException('404');

    }

    

}



public $defaultAction = ‘all’; is working for me.

Find something new.

If I set ‘enableStrictParsing’ => false and delete all ‘rules’ it works.

Help please, what’s wrong with my rules?


'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'enableStrictParsing' => true,

            'rules' => [

                [

                    'pattern' => '',

                    'route' => '',

                    'suffix' => ''

                ],

                

                [

                    'pattern' => '/<action>',

                    'route' => 'site/<action>',

                    'suffix' => ''

                ],


                [

                    'pattern' => '<controller>/<action>/<id:\d+>',

                    'route' => '<controller>/<action>',

                    'suffix' => ''

                ],

                [

                    'pattern' => '<module>/<controller>/<action>/<id:\d+>',

                    'route' => '<module>/<controller>/<action>',

                    'suffix' => ''

                ],

                

                [

                    'pattern' => '<controller>/<action>',

                    'route' => '<controller>/<action>',

                    'suffix' => ''

                ],

                

                [

                    'pattern' => '<controller>/<action>',

                    'route' => '<controller>/',

                    'suffix' => ''

                ],


                [

                    'pattern' => '<module>/<controller>/<action>',

                    'route' => '<module>/<controller>/<action>',

                    'suffix' => ''

                ],

                


            ],

This part is wrong, when you call /tour system is trying to find site/tour action