How to Redirect to External URL in Laravel?
Hello Artisan,
In this guide, we are going to learn laravel redirect external url. In this article, we will implement a laravel redirect()->away. This post will give you a simple example of laravel redirect to external url from controller. I explained simply about laravel redirect to external link. Alright, let us dive into the details.
Sometimes you may need to redirect on external URL from our laravel application like if you use something like Amazon API, Paypal API etc. so, Laravel provide away() for redirect other external link for return redirect like bellow example:
Example:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DemoController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index(Request $request)
{
return redirect()->away('https://www.itsolutionstuff.com');
}
}
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Call Controller Function in Blade Laravel?
- Laravel Redirect to Route from Controller Example
- How to Call a Controller Function in Another Controller in Laravel?
- Laravel Call Function from Same Controller Example
- Laravel 9 Resource Route and Controller Example
- How to Force Redirect HTTP to HTTPS in Laravel?
- Laravel Redirect Back with Input and Error Messages Example
- How to Create Resource Controller in Laravel?
- Laravel Redirect to URL using redirect() Helper
- How to Redirect to External URL in Laravel?
- How to Redirect Route with Querystring in Laravel?
- Laravel Redirect Back to Previous Page After Login Example