tags:

views:

57

answers:

1

I've noticed that if your site is located at the root of the domain, like www.example.com instead of www.example.com/website/ then if you set your $loginUrl='/' in the config of Yii, the redirection will not work, because the url is stripped to an empty string while processing. To overcome that I've added

public function init() {
    parent::init();
    $this->loginUrl = Yii::app()->getRequest()->getBaseUrl(true);
}

in my WebUser.php

I hope this will be helpful to someone.

However, does anyone know a better way of doing

$this->redirect('/');

in the controller rather than

$this->redirect(Yii::app()->getRequest()->getBaseUrl(true));
+1  A: 

The best (correct) way of redirecting users to the homepage is using Yii::app()->homeUrl instead of '/'.

Karolis