Posted by Arjun on Saturday 25th November 2017

Laravel 5.5 - The Route::redirect method

redirect Laravel 5.x Laravel 5.5

Laravel 5.5 introduced new Router class method called redirect, which gives the flexibility to redirect to other URLs directly without creating a controller or closure.

How to use Route::redirect()

Let's define a route with Route::redirect() method, if user tries to access http://localhost:8000/contact page, redirect the user to http://locahost:8000/contact-us page.

Route::redirect('/contact', '/contact-us');

The Route::redirect() is very useful method when you want to redirect to a specific URI by accessing another URI.