라라벨 https 리다이렉트 미들웨어

1 개요[ | ]

라라벨 https 리다이렉트 미들웨어
app/Http/Middleware/ForceHttps.php
namespace App\Http\Middleware;

use Closure;

class ForceHttps
{
	public function handle($request, Closure $next) {
		if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'http' ) {
			return redirect()->secure($request->getRequestUri());
		}
		return $next($request);
	}
}
app/Http/Middleware/ForceHttps.php
...
class Kernel extends HttpKernel
{
    ...
    protected $routeMiddleware = [
        'https' => \App\Http\Middleware\ForceHttps::class,
        ...
    ];
}
routes/web.php
Route::get('login','LoginController@index')->middleware('https');

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}