Allow action to access without login

I am having couple of controllers

  • SiteController

  • ProjectController

and they both have action named ‘Index’.

Now,what i want is to allow access of ‘site/index’ action without logged in and do not allow access of ‘project/index’ action.i have configure ‘web.php’ file as below.

‘as beforeRequest’ => [

	'class' => 'yii\filters\AccessControl',


	'rules' => [


		[


			'actions' => ['login','index'],


			'allow' => true,


		],


		[


			'allow' => true,


			'roles' => ['@'],


        ],


	],


],

but this allows both index action to be accessed without logged in.is there any way to do this expect renaming actions?

Filter in controller?

yii\filters\AccessControl

That worked fine Thanks,but is there any way we can do it in general instead of setting access in all controllers?