In this example, we will see how to redirect users using laravel Route::redirect()
method in Laravel 9 application. Assume If you are defining a route that is going to redirect to another URI, you may use the Route::redirect
method. This method accepts two parameters. The first parameter is URI and the second parameter is redirected URI. Let's see the example:
<?php
use Illuminate\Support\Facades\Route;
Route::redirect('/here', '/there');
The above code is the same as the below code:
<?php
use Illuminate\Support\Facades\Route;
Route::get('/here', function () {
return redirect('/there');
});
Read also: Laravel 9 Routing Example Tutorial
Hope it can help you.