2016-01-29 61 views
0

我正在使用cloudflare CDN來「增壓」我的網站,並且我正在使用它的完整SSL來提高我的網站的安全性。不過,我在我的網站上經常遇到error 523。我已經諮詢了cloudflare和託管公司的幫助,但都表示他們的方面沒有問題。所以,我必須做我自己的實驗來嘗試解決這個問題。如何強制Laravel生成https鏈接?

現在,我嘗試使SSL充分發揮作用。由於服務器和Cloudflare之間的連接是通過不安全的連接(http)完成的,因此laravel生成的鏈接均爲http格式。這帶來的問題是,我所有的CSS & JS不加載在Firefox上,並返回錯誤說Blocked loading mixed active content

那麼,我該如何強制Laravel使用https連接生成URL呢?

+0

我不知道'laravel'。但我認爲你可以通過'htaccess'來完成。看到[這](http://stackoverflow.com/questions/10489895/http-to-https-through-htaccess) – roullie

+0

你目前的代碼看起來如何? – patricus

+0

@patricus我的代碼看起來像這樣'asset('css/bootstrap.min.css')'''url($ language。'/ index')' – user1995781

回答

0

您可以在路線執行https,如:

Route::get('order/details/{id}', ['uses' => '[email protected]', 'as' => 'order.details', 'https']); 
0

無論是asset()url()輔助方法採取$secure布爾作爲他們的最後一個參數。如果你通過這個爲true,這些方法將生成安全的網址:

// pass true as second parameter to asset 
asset('css/bootstrap.min.css', true) 

// pass true as third parameter to url 
url($language.'/index', [], true)