YII 2.0 $this->redirect to another controller or action is not working


I am facing small redirection issue

after successful login getting blank page not redirecting to another controller action or same controller action

i tried to redirect using these options


return $this->goHome();

return $this->redirect(array(’/site/dashboard’));

return $this->redirect(’/site/dashboard’,302);

Please help me asap i’ll be thankful for solutions

Where and how did you call one of these lines?

Please show us the controller code where you are trying to redirect.

Try this:

return $this->redirect(array(‘site/dashboard’));

It will definitely work!

Hello Softark,

i am just trying login and redirect after success but its not working so i tried simple 2 action to redirect on page load

then also its not working

please check these 2 actions

   public function actionTest(){

	//return \Yii::$app->response->redirect(Url::to(['show']));

        return $this->redirect(array('site/show'));

       // Yii::$app->getResponse()->redirect('/requirements');

        //return $this->goHome();

        //return $this->redirect(array('/site/dashboard'));

        //return $this->redirect('/site/dashboard',302);



    public function actionShow(){

       //your action here

        echo "asd asd sadssd"; exit;


this simple redirection also not working getting blank page here is my PHPinfo page


It’s so strange. I really don’t know what’s going on.

Did you check the server log?

Yes its really strange i tried this on main domain its working fine but if i am using any sub domain its not working

there no error in logs also i just understand above mention point

Sounds like a problem with the server configuration.

What if you put a simple "index.html" saying "Hello world!" in "sub.domain/site/show" directory?

If i put url manually in address bar its working fine but only issue on form submit like if i am adding any record so after successful insert i am redirecting to view page or listing page but its not redirecting and showing same action with blank page

if i am trying to login same issue showing blank page after form submit but if i manually call internal page url from addressbar its showing me as a logged in user but not redirecting after successful login or logout

Is there a setting in your htaccess, if you are using that, which specifies the base path?

this is my .htaccess code

RewriteEngine on

# If a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward it to index.php

RewriteRule . index.php

I think the URL Helper in \yii\helpers\Url could do the Job for you.


This would take Care of Subdomains too.