ItSolutionStuff.com

How to Redirect to External URL in Laravel?

By Hardik Savani • November 5, 2023
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...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Call Controller Function in Blade Laravel?

Read Now →

Laravel Redirect to Route from Controller Example

Read Now →

How to Call a Controller Function in Another Controller in Laravel?

Read Now →

Laravel Call Function from Same Controller Example

Read Now →

Laravel 9 Resource Route and Controller Example

Read Now →

How to Force Redirect HTTP to HTTPS in Laravel?

Read Now →

Laravel Redirect Back with Input and Error Messages Example

Read Now →

How to Create Resource Controller in Laravel?

Read Now →

Laravel Redirect to URL using redirect() Helper

Read Now →

How to Redirect to External URL in Laravel?

Read Now →

How to Redirect Route with Querystring in Laravel?

Read Now →

Laravel Redirect Back to Previous Page After Login Example

Read Now →