This webpage has a redirect loop/The page isn't redirecting properly

I am getting the following errors when I try to access a certain page in a module

In Firefox it shows as

" The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept

cookies.

"

In Chrome it is showing as

"This webpage has a redirect loop

The webpage at http://localhost/yiixyz/index.php?r=user/login has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

"

:D

Check your accessRules() function on the controller class, "UserController.php" in your case.

You need to let "Guest" user or ANY user to perform the action, "actionLogin()" in this case.

just add ‘login’ to “actions array” and check “users array” value is ‘*’




// FILE = WebRoot/protected/controllers/UserController.php


//...

public function accessRules()

	{

		return array(

			array('allow',  // allow all users to perform 'index' and 'view' actions

				'actions'=>array('index','view','login'),

				'users'=>array('*'),

	//...

	}

//...	



I had the same problem when deleted the default login and then try to create my own, that solve my problem. ;)

…(this is my first POST/REPLY and i am spanish speaker)Correct my entry please. :unsure:

LeoCS is right. It seems that the action ‘login’ is not allowed to be viewed by any users. Yii’s default behavior when a user tries to access a member-only page is to redirect it to the login page, and since your login action is not allowed to guest users, Yii is redirecting again to the login page thus resulting in an endless loop and too-many-redirect error.

If you’re using an access control like Rights of SRBAC, look into the documentation and see what method to use in allowing set of actions to any users.

I have that very same problem,

I use the userGroups extension… on development it works flawlessly but [color="#0000FF"]on the production server we have that redirect loop[/color]… and I can’t seem to find the source of it.

[color="#006400"]Ubuntu Server 14.04, PHP 5.5.9-1ubuntu4.9 (cli)[/color]

[color="#FF0000"]I have commented:

UserController::filters() and UserController::accessRules()

so there’s no security to test this, and I still have a redirect loop[/color]

CONTROLLER: /modules/userGroups/controllers/UserController




public function actionLogin()

	{

		$model = new UserGroupsUser('login');


		// if it is ajax validation request

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

		{

			echo CActiveForm::validate($model);

			Yii::app()->end();

		}


		// collect user input data

		if(isset($_POST['UserGroupsUser']))

		{

			$model->attributes=$_POST['UserGroupsUser'];

			// validate user input and redirect to the previous page if valid

			if($model->validate() && $model->login()) {

                                if( isset($_SESSION["redirectUrl"]) )

                                {

                                        $urlBuff = $_SESSION["redirectUrl"];

                                        unset($_SESSION["redirectUrl"]);

                                        $this->redirect($urlBuff);

                                }

                                if( isset($_SESSION["timeoutRedirect"]) )

                                {

                                        $urlTimeBuff = $_SESSION["timeoutRedirect"];

                                        unset($_SESSION["timeoutRedirect"]);                                        

                                        $this->redirect($urlTimeBuff);

                                }

				$this->redirect(Yii::app()->user->returnUrl);

			}

		}  

                $this->layout = '//layouts/client'; 

                

		// display the login form

		if (Yii::app()->request->isAjaxRequest || isset($_GET['_isAjax']))

			$this->renderPartial('/user/login',array('model'=>$model));

		else

			$this->render('/user/login',array('model'=>$model));

	}



HERE: If I comment




//if (Yii::app()->request->isAjaxRequest || isset($_GET['_isAjax']))

  $this->renderPartial('/user/login',array('model'=>$model));

// else

// $this->render('/user/login',array('model'=>$model));



[color="#0000FF"]I have a basic form with no layout nothing but is works, I can login[/color]

[color="#FF0000"]If I use: $this->render(’/user/login’,array(‘model’=>$model)); I get a redirect loop [/color] <_<

VIEW: /modules/userGroups/views/user/login.php




<?php $this->breadcrumbs=array(

	'login',

); 


?>

<div id="userGroups-container" style="padding: 15px;">

	<?php if(isset(Yii::app()->request->cookies['success'])): ?>

	<div class="info">

		<?php echo Yii::app()->request->cookies['success']->value; ?>

		<?php unset(Yii::app()->request->cookies['success']);?>

	</div>

	<?php endif; ?>

	<?php if(Yii::app()->user->hasFlash('success')):?>

    <div class="info">

        <?php echo Yii::app()->user->getFlash('success'); ?>

    </div>

	<?php endif; ?>

	<?php if(Yii::app()->user->hasFlash('mail')):?>

    <div class="info">

        <?php echo Yii::app()->user->getFlash('mail'); ?>

    </div>

	<?php endif; ?>

	

	<?php $form=$this->beginWidget('CActiveForm', array(

		'id'=>'login-form',

		'enableAjaxValidation'=>false,

		'focus'=>array($model, 'username'),

	)); ?>

               

                <!--<div class="form row container"  >-->

                        <?php // echo $form->errorSummary($model); ?>

                <!--</div>-->

          <div class="form center">  

		<p class="note"><?php echo Yii::t('userGroupsModule.general', 'Fields with {*} are required.', array('{*}' => '<span class="required">*</span>'))?></p>                		

		<div class="row">

			<?php echo $form->labelEx($model,'username'); ?>

			<?php echo $form->textField($model,'username', array("class"=>"form-control") ); ?>

			<?php echo $form->error($model,'username'); ?>

		</div>

		<div class="row">

			<?php echo $form->labelEx($model,'password'); ?>

			<?php echo $form->passwordField($model,'password', array("class"=>"form-control") ); ?>

			<?php echo $form->error($model,'password'); ?>

		</div>

	

		<div class="row checkbox">

			<?php echo $form->checkBox($model,'rememberMe',["class"=>"btn btn-primary"]); ?>

			<?php echo $form->label($model,'rememberMe'); ?>

			<?php echo $form->error($model,'rememberMe'); ?>

		</div>

		<?php if (UserGroupsConfiguration::findRule('registration')): ?>

		<div class="row">	

		<?php echo CHtml::link(Yii::t('userGroupsModule.general', 'register'), array('/userGroups/user/register'))?>

		</div>

		<?php endif; ?>

		<div class="row buttons">

			<?php echo CHtml::submitButton('Login',["class"=>"btn btn-primary"]); ?>

		</div>

	<?php $this->endWidget(); ?>

	</div><!-- form -->

</div>



Someone have and idea?