In this article, I will share with you how to make force redirect website URL HTTP to HTTPS in laravel. as you mark, sometimes we install SSL in our live laravel website and still not auto redirect it HTTPS. so, here I have seen to you how to resolve this issue with some simple steps.
open your .htaccess file and add the following 2 line code in your file.
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
open your app/Providers/AppServiceProvider.php file and make the following change. please don't use this option in your local. because after you make this change your laravel application not run on the local server. this option only works in live.
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// force redirect https.
\URL::forceScheme('https');
}
}
i hope you like this article.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to set the height of a div element dynamically using jQuery
Use the JavaScript height() method Yo...Use PHP Code into Laravel Blade
in this article, I will share with you h...Laravel Create Custom Helper Function
In this article, we will share with you...How to integrate paypal payment gateway in laravel 5.4
Hello, today laravelcode share with you...How to create Helpers function in Laravel 8
Laravel ships with rich global function...