Laravel Redirect All Requests To HTTPS


Laravel Redirect All Requests To HTTPS : We sometimes need to redirect all requests to https in laravel. Here in this tutorial we are going to explain how you can redirect all the request to https in Laravel.


Laravel Redirect All Requests To HTTPS

You can use the app/filters.php file and it’s block App::before() check each request if it is not secure redirect it to the https as below –

Laravel Redirect All Requests To HTTPS:

App::before(function($request)
{
    if( ! Request::secure())
    {
        return Redirect::secure(Request::path());
    }
});

The above example will redirect all request to secure https request.


Advertisements

Add Comment

📖 Read More