如何在laravel 5.4中实现HTTPS [英] How to implement HTTPS in laravel 5.4
问题描述
我与OVH(法国)有一个共享主机,我有我的域名的Let's Encrypt证书。
I have a shared hosting with OVH(France) and i have the "Let's Encrypt" certificate for my domain.
然而,我到处寻找重定向所有请求从laravel 5.4中的HTTP到HTTPS
however, i looked everywhere for redirecting all requests from HTTP to HTTPS in laravel 5.4
我找到了一个.htacces重定向的解决方案,但我经常在浏览器上特别是Google Chrome上出现TOO_MANY_REDIRECT错误。
i have found a solution with ".htacces redirecting" but i often have "TOO_MANY_REDIRECT" errors on browsers specially Google Chrome.
任何人都有想法重定向所有
PS:我的共享托管服务器上没有sudo权限(仅使用ssh进行用户访问)
Anyone have an idea for redirecting all PS : i don't have "sudo" rights on my shared hosting server (just user access with ssh)
问候,
推荐答案
无需修改 .htaccess 文件,你可以强制你的Laravel应用程序中的https协议添加:
Without modify the .htaccess file, you can force the https protocol in your Laravel application adding:
function boot() {
URL::forceScheme('https');
... your code
}
在您的 AppServiceProvider.php
。
这篇关于如何在laravel 5.4中实现HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!