Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel将所有请求重定向到非HTTPS_Php_Ssl_Laravel - Fatal编程技术网

Php Laravel将所有请求重定向到非HTTPS

Php Laravel将所有请求重定向到非HTTPS,php,ssl,laravel,Php,Ssl,Laravel,有很多问题询问如何发出Laravel请求HTTPS,但如何使其非HTTPS。我想确保所有不是订单页面的页面都不是SSL。基本上与Redirect::secure相反 //in a filter if( Request::path() != ORDER_PAGE && Request::secure()){ //do the opposite of this: return Redirect::secure(Request::path());

有很多问题询问如何发出Laravel请求HTTPS,但如何使其HTTPS。我想确保所有不是订单页面的页面都不是SSL。基本上与Redirect::secure相反

    //in a filter

    if( Request::path() != ORDER_PAGE && Request::secure()){
    //do the opposite of this:
    return Redirect::secure(Request::path());
    }
试试这个 //在过滤器中

if( Request::path() != ORDER_PAGE && Request::secure()){
//do the opposite of this:
return Redirect::to(Request::path());
}

也许这对你有帮助

我用一个过滤器解决了这个问题,我将它映射到所有需要创建非SSL的路由

Route::filter('prevent.ssl', function () {
    if (Request::secure()) {
        return Redirect::to(Request::getRequestUri(), 302, array(), false);
    }
});
仅具有非SSL的路由示例

Route::get('/your_no_ssl_url', array(
    'before' => 'prevent.ssl',
    'uses'   => 'yourController@method',
));

如果打开
https://example.app/your_no_ssl_url
您将被重定向到
http://example.app/your_no_ssl_url

响应的Thx。但是我试过了,它仍然重定向到https。它创建了一个重定向循环。这可能已经晚了,但它可能会帮助未来的访问者。看看