aymanesoft aymanesoft - 1 year ago 80
PHP Question

How to implement HTTPS in laravel 5.4

I have a shared hosting with OVH(France) and i have the "Let's Encrypt" certificate for my domain.

however, i looked everywhere for redirecting all requests from HTTP to HTTPS in laravel 5.4

i have found a solution with ".htacces redirecting" but i often have "TOO_MANY_REDIRECT" errors on browsers specially Google Chrome.

Anyone have an idea for redirecting all
PS : i don't have "sudo" rights on my shared hosting server (just user access with ssh)

Regards,

Answer Source

Without modify the .htaccess file, you can force the https protocol in your Laravel application adding:

function boot() {
     URL::forceScheme('https');
     ... your code
}

In your AppServiceProvider.php.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download