How to Set URL without Http of Other Site in Laravel - TechvBlogs

How to Set URL without Http of Other Site in Laravel

In this article, You will learn How to Set URL without Http of Other Site in Laravel.


Smit Pipaliya - Author - TechvBlogs
Smit Pipaliya
 

4 months ago

TechvBlogs - Google News

When working with Laravel, redirecting to URLs outside of your current site may pose a challenge. While traditional anchor tags like href="https://techvblogs.com" might not work as expected, Laravel provides a solution for this situation.

How to Set URL without Http of Other Site in Laravel

You can set a URL without specifying the protocol (http or https) for external sites in a Laravel website. Here's how you can achieve this:

use Illuminate\Support\Facades\Redirect;

$url = 'techvblogs.com'; // Replace with the desired external URL

return Redirect::to('//'.$url);

By prefixing the URL with //, Laravel will automatically use the same protocol (http or https) as the current page, allowing you to redirect to external sites seamlessly.

Comments (0)

Comment


Note: All Input Fields are required.