How to Force HTTPS in Laravel

It is possible to force 301 redirects to HTTPS site-wide from within your Laravel application. Doing this from within Laravel will also convert all links using a route method into HTTPS.


We can force HTTPS in Laravel by placing URL::forceScheme() in the boot function inside of the AppServiceProvider class.


class AppServiceProvider extends ServiceProvider
   * Bootstrap any application services.
   * @return void

  public function boot()


And that it is all you have to do. Unless you have set up HTTPS on your local development environment, you will need to set forceScheme to http while working on your application.