How Can I Get The Full Url Including The Http Or Https Laravel

- 1 answer

ive been looking around and cant find a solid answer.

Im trying to retrieve the full url including the https or http. reason why is because my development environment is a secured environment (c9.ide) so all style sheets point to a https cdn.

but when i deploy to production which isnt a https all my style sheets break because http is trying to load https stuff but its not a secure site, so i get error messages.

my goal is to achieve this in code

if(site_is_https) {
//load all of these files with proper url that points to https
} else {
//load all of these files with proper url that points to http

this is the only way i can think of solving this problem I'm having unless someone else knows a better solution. also how would i implement this in a mvc way instead of the logic in the header file



In addition to @JosephSilber's answer, another option would be to use a "protocol relative url".

Instead of or,

you would just use

By leaving off the specific protocol (keep the double slashes), the resource will be served over whichever protocol is currently being used. If you're on https, it'll be served over https. If you're on http, it'll be served over http.