如果HTTPS激活,Laravel请求HTTP [英] Laravel request HTTP if HTTPS activated
问题描述
//安全应用程序路由
Route :: filter('force.ssl',function()
{
if(!Request :: secure())
{
return Redirect :: secure Request :: path());
}
});
然而,在两个特定的页面中,用户必须处于http模式(外部服务器不接受https请求)。这同样的逻辑怎么能够反向应用?我假设这样的事情,但重定向不安全?
//安全应用程序路由
Route :: filter('force。函数()
{
if(Request :: secure())
{
return Redirect :: unsecure(Request :: path());
}
});
尝试重定向::至>
$ secure
标记设置为 false
return Redirect :: to(Request :: path(),302,array(),false);
Redirect :: secure
调用 Redirect :: to
并将最后一个参数设置为 true
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());
}
});
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
这篇关于如果HTTPS激活,Laravel请求HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!