Home > Tips & Tricks > How to Set URL Without http in Laravel?

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 😉

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment