Laravel HTTP to HTTPS Redirect Example
Hello Dev,
As we speak, i we’ll present you laravel HTTP to HTTPS redirect instance. This text gives you easy instance of laravel HTTP to HTTPS redirect instance. you’ll be taught laravel HTTP to HTTPS redirect instance. So let’s comply with few step to create laravel HTTP to HTTPS redirect instance.
For this I gives you two examples, one from htaccess file and the opposite from laravel middleware. this Instance you should utilize with laravel 6, laravel 7 and laravel eight model as properly.
So let’s comply with few step to create laravel HTTP to HTTPS redirect instance.
Laravel eight Drive Redirect HTTP to HTTPS utilizing htaccess
.htaccess
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Choices -MultiViews -Indexes </IfModule> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Deal with Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Ship Requests To Entrance Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
Laravel eight Drive Redirect HTTP to HTTPS utilizing Supplier
app/Suppliers/AppServiceProvider.php
<?php namespace AppProviders; use IlluminateSupportServiceProvider; use IlluminatePaginationPaginator; class AppServiceProvider extends ServiceProvider { /** * Register any utility providers. * * @return void */ public perform register() { } /** * Bootstrap any utility providers. * * @return void */ public perform boot() { URL::forceScheme('https'); Paginator::useBootstrap(); } }
Komentar
Posting Komentar