xxxxxxxxxx
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
xxxxxxxxxx
// app/Providers/AppServiceProvider.php
URL::forceScheme('https');
xxxxxxxxxx
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
xxxxxxxxxx
<?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');
Paginator::useBootstrap();
}
}
xxxxxxxxxx
// Create Middleware file: app/Http/Middleware/HttpsProtocol.php
namespace App\Http\Middleware;
use Closure;
class HttpsProtocol {
public function handle($request, Closure $next)
{
if (!$request->secure()) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
}
//Next we have to register this middleware in Kernel.php file as bellow following code.
//You path for Kernel: app/Http/Kernel.php
//You just need to add this line in the middleware Groups section.
\App\Http\Middleware\HttpsProtocol::class,