简体   繁体   English

Laravel 5.4 外部 url 重定向无法正常工作

[英]Laravel 5.4 Redirect Not Working Correctly for external url

I have the following __construct() in a Controller (this is simply for testing):我在控制器中有以下 __construct() (这只是为了测试):

public function __construct( ) {

    $this->middleware( 'auth' );

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

}

The application is not redirecting at all to the external URL, instead it just flows through and continues into the method that was called.应用程序根本没有重定向到外部 URL,而是只是流过并继续进入被调用的方法。 In desperation I tried it without the return directive, but the same behavior happened.无奈之下,我在没有 return 指令的情况下尝试了它,但发生了相同的行为。 Am I missing something with the redirect call?我在重定向调用中遗漏了什么吗?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM