Home » Php » Laravel 4: Redirect to a given url

Laravel 4: Redirect to a given url

Posted by: admin November 28, 2017 Leave a comment

Questions:

Is there a method in Redirect class of laravel where the parameter is a complete url? We all know parameters to these methods are just route name,action, slash,..etc but what I want now is like

return Redirect::foo('https://bla.com/?yken=KuQxIVTNRctA69VAL6lYMRo0');
Answers:

Yes, it’s

return Redirect::to('http://heera.it');

Check the documentation.

Update: Redirect::away('url') (For external link, Laravel Version 4.19):

public function away($path, $status = 302, $headers = array())
{
    return $this->createRedirect($path, $status, $headers);
}

Questions:
Answers:

Both Redirect::to() and Redirect::away() should work.

Difference

Redirect::to() does additional URL checks and generations. Those
additional steps are done in Illuminate\Routing\UrlGenerator and do
the following, if the passed URL is not a fully valid URL (even with
protocol):

Determines if URL is secure
rawurlencode() the URL
trim() URL

src : https://medium.com/@zwacky/laravel-redirect-to-vs-redirect-away-dd875579951f

Leave a Reply

Your email address will not be published. Required fields are marked *