Laravel Force Redirect Http To Https Using Htaccess

In this laravel redirect http to https htaccess tutorial i am going to show you how we redirect http to https in Laravel application using htaccess code. This force https laravel article will give you a simple example of way to force redirect to https htaccess laravel.

I want to share with you laravel force https provider. From this quick laravel https redirect tutorial you will learn laravel force https htaccess. In this example i will share with two example, one is middleware and another is htaccsss file.

Force Redirect HTTP to HTTPS using htaccess Laravel

First i will share with you using .htaccess file example:

public/.htaccess

 

In this second method, i will use laravel service provider to redirect http to https in laravel.

app/Providers/AppServiceProvider.php

namespace App\Providers;
  
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
   
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
          
    }
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        \URL::forceScheme('https');
    }
}

 

Read also : How to redirect example.com to www.example.com

 

Hope it can help you.

 

#laravel #redirect-https #https-htaccess