Yii::app()->User->Returnurl Returns Index.php/account/favicon.ico

user directly access a secure page through bookmark or history. he is then redirected to the login page. I am trying to redirect user to referral url after successfully logged in. but the Yii::app()->user->returnUrl returns index.php/account/favicon.ico.

Yii::app()->request->urlReferrer return null.

I’ve gone through many posts which discusses Yii::app()->user->returnUrl and Yii::app()->request->urlReferrer

AccountController extends CController

the secure page for eg index.php/user/dashboard userController extends CController

components/controller.php:




<?php


public function beforeAction($action)

{

                if( Yii::app()->user->isGuest )

                {

                        Yii::app()->user->setReturnUrl(Yii::app()->request->getUrl());

                        $this->redirect(array('account/login'));

                }


}


?>



controllers/AccountController.php




<?php


class AccountController extends CController

{

    public $layout = 'login_layout';


     public function actionLogin()

    {

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

    }


?>



views/login/loginform.php




<?php

               echo "parent.location.href = '" . Yii::app()->user->returnUrl . "'";

?>



It looks like you’re using a relative url for favicon.ico

In your layout, there’s probably a line like this:


<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

Change it to use an absolute path like this:


<link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/favicon.ico" type="image/x-icon" />

I know this post is several months old, but I’d like to help anyone who comes here with the same problem, as I did.

It will do this sometimes if it can’t find an CSS, js, image, icon file on the index page. Don’t really know why but it does. I noticed it dosent do it on a real server only on my local dev machine.