How to Set URL Without http in Laravel?

Today I will tell you in this trick how you can set the URL to other sites without http in laravel. This means you don’t need to add the http or https as prefixes of the domain name.

Let’s say you are working on laravel project and the project has a requirement to set the URL which will redirect to another site.

But if you give the full URL with https or http like “https://google.com” in laravel then it will not work, it will not redirect to that URL. It will only redirect you to the current site.

But you don’t need to worry about this because we have a solution to this problem. And you can set the app URL or any other site URL in laravel without http or https and work properly.

So simply set the URL like the following link.

As you can see in the above examples we have given the href attribute value starting with // and without http or https. And now it will allow laravel to redirect to that URL.

Being Tricky 😉

Leave a Reply

Your email address will not be published.