强制Laravel使用HTTPS版本 [英] Force Laravel to use HTTPS version
问题描述
我有一个laravel网站,我正在尝试使所有内容都可以与SSL一起使用.
尽管Laravel似乎想使用http代替.
例如,我正在使用form
元素,并且该方法自动发送到http.使用内置的style
,script
链接也是一样,我将其全部更改为静态工作(常规ol'HTML).我无法弄清的最后一件事是分页(使用jscroll).
我有这一行:
I have a laravel site and I'm trying to get everything to work on with SSL.
Though it seems that Laravel wants to use http instead.
For example I was using the form
element and the method was automatically sending to http. The same thing using the built in style
, script
links which I changed all to work statically (regular ol' HTML). The last thing which I can't manage to figure out is the pagination (using jscroll).
I have this row:
{!! $plugins->appends(['tag' => $param2, 'search' => $param1 ])->render() !!}
哪个打印此:
<ul class="pager">
<li class="disabled"><span>«</span></li>
<li class="jscroll-next-parent" style="display: none;"><a href="http://siteurl.net/pagename/page/?tag=XXX&search=&page=2" rel="next">»</a>
</li>
</ul>
您知道如何将其更改为https吗? 谢谢!
Any idea how I change that to be https? Thanks!
推荐答案
尝试一下,请转到AppServiceProvider将此代码放入启动方法中:
Try this, go to AppServiceProvider place this code in the boot method:
\URL::forceScheme('https');
课程:
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
URL::forceScheme('https');
}
}
其他方法是通过.htaccess强制执行:
Other way is enforce by .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
记住要清除浏览器中的缓存(然后htaccess才能正常工作).
Remember about clearing cache in browser (then htaccess will work correctly).
祝你好运!
这篇关于强制Laravel使用HTTPS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!