laravel-https-redirect maintained by ilvalerione
Description
Flexible https redirect for Laravel based applications
Author
Last update
2019/10/29 09:06
(dev-master)
License
Downloads
34
Tags
Laravel https redirect
- Author: Valerio Barbera - valerio@aventuresrl.com
- Author Website: www.inspector.dev
Flexible https redirect for Laravel based applications
Install
composer require ilvalerione/laravel-https-redirect
Config
php artisan vendor:publish --provider="Aventure\HttpsRedirect\HttpsRedirectServiceProvider"
This command publish a new configuration file in your config directory
to list all environment names that you want force to https:
return [
'environments' => [
// 'local', <-- usually no
'development',
'test',
'production',
]
]
Or you can force all possible environment using wildcard:
return [
'environments' => '*'
]
Use
Add HttpsMiddleware middleware in your global middleware section:
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
...,
\Aventure\HttpsRedirect\Middleware\HttpsCheck::class,
];
...
Use as Route-Middleware
In alternative you can add middleware as named middleware in your Kernel file:
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $routeMiddleware = [
...,
'https_redirect' => \Aventure\HttpsRedirect\Middleware\HttpsCheck::class,
];
...
And use it programmatically in your routes configuration:
Route::middleware('https_redirect')->group(function(){
Route::view('example', 'example');
});
LICENSE
This package are licensed under the MIT license.