【问题标题】:Laravel 5.4 Redirect Not Working Correctly for external urlLaravel 5.4 重定向对于外部 url 不能正常工作
【发布时间】:2018-07-30 06:25:16
【问题描述】:

我在控制器中有以下 __construct() (这只是为了测试):

public function __construct( ) {

    $this->middleware( 'auth' );

    return redirect('http://www.google.com');

}

应用程序根本没有重定向到外部 URL,它只是流过并继续进入被调用的方法。绝望中我在没有返回指令的情况下尝试了它,但发生了同样的行为。我是否缺少重定向调用的某些内容?

【问题讨论】:

    标签: php laravel-5 model-view-controller routes


    【解决方案1】:

    Redirect::away 将创建对外部 URL 的重定向响应

       return Redirect::away('http://www.google.com');
    

    【讨论】:

      猜你喜欢
      • 2017-11-08
      • 2020-12-07
      • 2017-12-21
      • 2015-12-25
      • 2017-09-23
      • 1970-01-01
      • 2017-10-05
      • 2018-03-29
      • 1970-01-01
      相关资源
      最近更新 更多