Laravel Redirect::to() vs Redirect::away()

Simon Wicki
Sep 16, 2014

--

For external redirection

The use case here is to redirect the user to another domain. I haven’t come across Redirect::away() before, even though it’s been added in Laravel 4.0.8.

Redirect::to()

Redirect::away()

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

Simon Wicki is a Frontend Developer in Berlin. Passionate and fluent in Vue, Angular, React and Ionic. I love Hybrid Apps and books.

πŸ‘‰ Join me on Twitter to follow my latest updates.

--

--

Simon Wicki

πŸ’¬ Tech, frontend & non-fiction books πŸ‘¨β€πŸ’» Ex maker at justwatch.com πŸ”” Creator of notyfy.co πŸ§™β€β™‚οΈ Freelancer