How to Set URL without Http of Other Site in Laravel: Practical Guide - Techvblogs

How to Set URL without Http of Other Site in Laravel: Practical Guide

Learn how to set URL without http of other site in Laravel for clean and flexible link management in your projects.


Smit Pipaliya - Author - Techvblogs
Smit Pipaliya
 

3 days 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.