2016-07-24 116 views
1

我使用的是最新版本的laravel 5.2的,我想在HTTPS协议Laravel - 让laravel 5应用程序使用HTTPS

我从搜索找到运行孔程序是:

  1. 设置一个过滤器,但filter.php没有找到任何更在此 版本
  2. 设置在某种程度上服务器,使之,但我不能,因为我是新
  3. 实施中间件,我无法理解太

我想在我的应用程序中实现https,什么是最佳方式以及如何实现? 我会感谢您的详细解答。

注:本地主机上开发,XAMP使用时,Windows 10

+0

这听起来像你需要做一些更多的研究来了解你们的问题解决。发布一些代码,有人可以帮助 – nagyben

+2

refrences: http://stackoverflow.com/questions/19967788/laravel-redirect-all-requests-to-https http://stackoverflow.com/questions/38554636/ laravel-make-laravel-5-app-use-https http://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https –

回答

1

你可以使用middleware

class HttpsMiddleware { 

    public function handle($request, Closure $next) 
    { 
     if (! $request->secure() && app()->environment() === 'production') { 
      return redirect()->secure($request->path()); 
     } 

     return $next($request); 
    } 
} 
+0

你能解释更多吗?.. –