How do you redirect routes in Laravel?

How do you redirect routes in Laravel?

Answer: In Laravel, you can redirect routes using the `redirect()` helper or the `Route::redirect()` method. For example:

1. Using the `redirect()` helper:
“`php
Route::get(‘/old-url’, function () {
return redirect(‘/new-url’);
});
“`

2. Using `Route::redirect()`:
“`php
Route::redirect(‘/old-url’, ‘/new-url’);
“`

Both methods will send a 302 HTTP response to the client, redirecting them from the old URL to the new URL.

Related Questions & Topics

Powered and designed by igetvapeaustore.com | © 2024 codestap.com.