Step 2: Make sure you set up the route for your test.php file in the routes.php file. You can find routes.php at app/Http. Here we are renaming the route to testing. We have set up another route for redirecting the request to testing route. This new route has been named as redirect.

Step 3: To test the route’s name, paste the URL: http://localhost:8000/redirect into the web server and the final output will appear like the following.

Explanation: Once you execute the mentioned URL, you will be redirected to the test URL: http://localhost:8000/test. But this URL will automatically redirect you to the testing route.

Redirection To Controller Actions
By now, you have clearly understood that we can redirect to the named route. But, you must also know that redirection to controller actions is also possible. This can be done with the help of action() method. For this, you need 2 arguments which are: the name of the action and the controller itself. And in case, there is any other parameter that you want to pass in the action() method then pass it as the second argument.

The following example will help you to understand this concept clearly.Step 1: Create a controller with the name RedirectController. For the creation of the controller, execute the following command on the command prompt (cmd) or on the terminal.

laravel> php artisan make:controller RedirectController –plain

Step 2: Once you create the controller successfully then include the given code to the RedirectController.php file. You can find this file at app/Http/Controllers/.