return $this->redirect(Yii::$app->request->referrer); //You need also take into account that referrer can be null: return $this->redirect(Yii::$app->request->referrer ?: Yii::$app->homeUrl);