2014-09-23 168 views
3

有很多詢問如何使Laravel請求HTTPS的問題,但你怎麼讓它HTTPS。我想確保所有不是訂單頁面的頁面都不是SSL。基本上與Redirect :: secure相反。Laravel重定向所有請求NON-HTTPS

//in a filter 

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

這可能會很晚,但它可能有助於未來的訪問者。看看[這個答案](http://stackoverflow.com/a/26875905/1903366) – lukasgeiter 2014-11-11 22:42:52

回答

1

試試這個 //在過濾器

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

可能這會幫助你。

+0

Thx爲響應。但是我嘗試過,它仍然重定向到https。它會創建一個重定向循環。 – jsorbo 2014-09-24 01:29:28

2

我與我映射到所有路由我需要讓非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' => '[email protected]', 
)); 

路線如果你打開https://example.app/your_no_ssl_url你會過濾解決它被重定向到http://example.app/your_no_ssl_url

相關問題