Get "PHP 8 in a Nutshell" (Now with PHP 8.5)
Amit Merchant
Amit Merchant

A blog on PHP, JavaScript, and more

Force HTTPS for all the URLs in Laravel

Here’s how you can do it using the URL::forceHttps() method.

Set this in your app’s boot() method of the service provider.

use Illuminate\Support\Facades\URL;

URL::forceHttps(app()->isProduction());

Was that useful? Consider leaving a

Tip

👋 Hi there! This is Amit, again. I write articles about all things web development. If you enjoy my work (the articles, the open-source projects, my general demeanour... anything really), consider leaving a tip & supporting the site. Your support is incredibly appreciated!

Comments?