1、域名https设置
在.env文件中设置 IS_HTTPS = true,APP_URL=https://baidu.com
在app/Providers/AppServiceProvider.php中,
public function boot()
{
if(env('IS_HTTPS')){
URL::forceScheme('https');
}
}
2、分页中生成https链接
在vendor\laravel\framework\src\Illuminate\Pagination\PaginationServiceProvider中,register方法下:
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
将上面代码修改如下:
if(env('IS_HTTPS')){
Paginator::currentPathResolver(function () {
$url = $this->app['request']->url();
if(strpos($url, 'https') !== false){
return $url;
}
return str_replace('http', 'https', $url);
});
}else{
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
}