Home Laravel Understanding Laravel Redirect method with Example

Understanding Laravel Redirect method with Example

laravel redirect

Laravel redirect function is a global helper function that comes in handy in many cases during programming. There are various types of redirect in Laravel. In this article, we will deep dive into each type in detail.


1. Redirect to URL

This is the simplest and most straightforward redirect usage in Laravel. We can simply give the URL where we want to redirect. This will redirect to any URL given as a parameter inside the redirect function. A well-explained example is given below.

//redirect to URL

return redirect('');

This will simply redirect to the homepage. It’s redirect output will be http://www.website.com/

//redirect to URL

return redirect('login');

This will redirect to the login page. Its redirect URL will be http://website.com/login




Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.