To know more about HTTP Redirects Visit Bajarangisoft site
Redirecting To External Domains
Sometimes you may need to redirect to a domain outside of your application. You may do so by calling the away
method, which creates a RedirectResponse
without any additional URL encoding, validation, or verification:
return redirect()->away('https://www.google.com');
Redirecting With Flashed Session Data
Redirecting to a new URL and flashing data to the session are usually done at the same time. Typically, this is done after successfully performing an action when you flash a success message to the session. For convenience, you may create a RedirectResponse
instance and flash data to the session in a single, fluent method chain:
Route::post('user/profile', function () {
// Update the user's profile...
return redirect('dashboard')->with('status', 'Profile updated!');
});
After the user is redirected, you may display the flashed message from the session.
For example, using Blade syntax:
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif