Black Hole - Please Help With Default Action

I redirect my users to the controller/action


video/player

when they login successfully. And it works fine.

But after someone logs in, I want to direct them to


video/player

by default also if there is no specific controller/action in the URL.

I thought this would work; here is my ‘site/index’




    public function actionIndex()

    {

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

        {

            $this->render('index');

        } else {

            $this->redirect(Yii::app()->createUrl('video/player'));

        }

    }



The first part works fine, if they are not logged in they are shown the ‘index’ view. But if they are already logged in it keeps reloading the ‘video/player’ on an infinite loop. Any ideas?

Solved: In my view for video/player I have some onpageload ajax calls still using the url format index.php?r=controller/action I changed them all to index.php/controller/action and it cured everything since I have url rewrite turned on

You should probably let Yii generate your ajax URL’s, to prevent this sort of thing. If I have embedded javascript, I use something like this:




<script type="text/javascript">

    var url = <?= CJavaScript::encode(Yii::app()->createUrl('your/route')) ?>;

</script>