CMOS
CMOS

Reputation: 2917

Laravel request HTTP if HTTPS activated

So I am having an issue where on most pages we need the user to be on SSL. So we have the following code with a route to force a user to go into SSL mode.

//secure app route
Route::filter('force.ssl', function()
{
    if( ! Request::secure())
    {
        return Redirect::secure(Request::path());
    }

});

This works perfectly however on two specific pages the user HAS to be in http mode (issue with external server not accepting https requests). How can this same logic be applied in reverse? I assume something like this but Redirect unsecure?

//secure app route
Route::filter('force.nossl', function()
{
    if(Request::secure())
    {
        return Redirect::unsecure(Request::path());
    }

});

Upvotes: 1

Views: 705

Answers (1)

lukasgeiter
lukasgeiter

Reputation: 152900

Try Redirect::to with the $secure flag set to false

return Redirect::to(Request::path(), 302, array(), false);

Redirect::secure is just a shortcut that calls Redirect::to with the last parameter set to true

Upvotes: 5

Related Questions