ERR_TOO_MANY_REDIRECTS in index.php YII

I need to block access to my index.php main page, I changed siteController.php with the following code:

public function accessRules() { return array( // allow all users to perform 'index' and 'view' actions * array('allow', 'actions' => array('index','view'), 'users' => array('admin'), ), // allow authenticated user to perform 'create' and 'update' actions @ array('allow', 'actions' => array('create','update'), 'users' => array('admin'), ), // allow admin user to perform 'admin' and 'delete' actions array('allow', 'actions' => array('admin','delete'), 'users' => array('admin'), ), // deny all users array('deny', 'users' => array('*'), ), ); } 

Because I have to provide access only for the administrator. After these manipulations, I saw that the redirect works, and the url becomes index.php / site / login, but instead of the login / password form, I got ERR_TOO_MANY_REDIRECTS . I hope you could understand me)

+4
source share
3 answers

I had the same problem, and the solution was to add an β€œerror” action to the rules, allowing all users to access it. I realized that after performing the update, he generated an error and could not access the error.

+1
source

I had the same problem and urlManager in config/main.php . The configuration of my urlManager was like this:

 'urlManager' => [ 'baseUrl' => $baseUrl, 'class' => 'yii\web\UrlManager', // Disable index.php 'showScriptName' => false, // Disable r= routes 'enablePrettyUrl' => true, 'rules' => [ '<controller:\w+>/<id:\w+>' => '<controller>', '<controller:\w+>/<action:\w+>/<id:\w+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ] ] 

and he should be

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

This is a relationship with RegEx. Here is the doc

+1
source

Add a login action to access the rules:

 ['allow', 'actions'=>['index','view','login'], 'users'=>['admin'], ], 
0
source

Source: https://habr.com/ru/post/1492242/


All Articles