Laravel include css, js using ssl

2019-04-13 05:36发布

问题:

I just installed an SSL cert onto my web server and I'm having some issues with my laravel setup.

I'm using

{{ HTML::style('css/style.css') }}

to include css and for js

{{ HTML::script('js/jquery.js') }}

Though when I load the page with https it seems to include the 2 with http instead of https.

Any idea why?

回答1:

I had an issue with this too. My SSL is redirecting fine, but the CSS and JS links generated by {{ HTML::style('css/style.css') }} and HTML::script('js/script.js') were linking to the http versions.

If you look at the Illuminate\Html\HtmlBuilder Documentation you'll see that you can specify the secure version as follows:

{{ HTML::style('css/style.css', array(), true) }}

{{ HTML::script('js/script.js', array(), true) }}

true means $secure flag is on.



回答2:

This might help.

In short you need to add a App:before in the app/filters.php.



标签: php ssl laravel