i9w3b / force-https
使用 Laravel 中间件强制将 http 重定向到 https
dev-master
2020-06-28 16:25 UTC
This package is auto-updated.
Last update: 2024-09-29 02:14:47 UTC
README
使用中间件强制将 http 重定向到 https
安装
执行以下命令
$ composer require i9w3b/force-https
如果您正在使用 Laravel 5.5 以下的版本,请将服务提供者在 config/app.php
中添加
I9W3b\ForceHttps\ForceHttpsServiceProvider::class,
可选
php artisan vendor:publish --provider="I9W3b\ForceHttps\ForceHttpsServiceProvider"
如何使用
为了将所有 http
路由重定向到 https
,需要使用 https
中间件,并在您的 .env 文件中添加 FORCE_HTTPS=true
。默认值 = true。
因此,如果 FORCE_HTTPS
被设置为 true
,这将强制 Laravel 的 URL 模式使用 HTTPS 前缀来生成所有链接。
示例
使用中间件 https
Route::group(['middleware' => ['https']], function () { Route::get('/', function () { return view('welcome'); }); /* outras rotas ... */ });
疑问/建议
如果您发现错误或有任何改进建议,请访问: 问题