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.