Yii how to redirect to absolute URL with json response
10,314
Solution 1
In controller, use:
$this->redirect("absolute URL");
If you want redirect to a specific action:
$this->redirect(array('controller/action'));
Solution 2
we can use getBaseUrl to get absolute url
$this->redirect(Yii::app()->getRequest()->getBaseUrl(true));
Author by
user3449452
Updated on June 24, 2022Comments
-
user3449452 almost 2 years
My Controler
function actionLogin() { //After success validation $url = $_POST['returnUrl']; // www.example.com/get_response/ $arr = array('response' => 'Failed', 'msg' => 'login success','tokenKey'=> 'token'); //How to send the response to url }
In my above code i have to send the $arr array to $url absolute URL.
I found some solutions for this is it works here?
Yii::$app->getResponse()->redirect('http://newdomain.com');
But i don't know how to use in my case or is there any better way