【问题标题】:"Redirecting to..." middle page in redirections LARAVEL 5.2“重定向到...”重定向 LARAVEL 5.2 中的中间页面
【发布时间】:2020-01-10 07:45:43
【问题描述】:

我在 Laravel 5.2 中遇到了一个非常罕见的问题

当我从一个 URL 重定向到另一个 URL 时,它会显示一个像这样的中间页面:


HTTP/1.1 302 Found
Cache-Control: no-cache
Content-Type:  text/html; charset=UTF-8
Location:      [URLEXAMPLE.COM]
Set-Cookie: new_session=a21c4b1e34cb6add684f7a43561ee59c9ab6a0e0; expires=Thu, 30-Jul-2325 07:37:10 GMT; path=/; httponly

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="1;url=[URLEXAMPLE.COM]" />

        <title>Redirecting to [URLEXAMPLE.COM]</title>
    </head>
    <body>
        Redirecting to [URLEXAMPLE.COM]>.
    </body>
</html>

控制器:

  public function test1(){
    return redirect()->to('/test2');
  }

  public function test2(){
    echo "hi";
  }

路线:

Route::get('test1', 'TestController@test1')->name('test1');
Route::get('test2', 'TestController@test2')->name('test2');

在 laravel 5.2 的全新安装中不会发生这种情况。

有人想出办法吗?

谢谢大家!

【问题讨论】:

标签: php laravel redirect


【解决方案1】:

你的方法调用是错误的,根据文档你应该这样做

    return redirect()->route('test2');
  }

文档:https://laravel.com/docs/5.2/routing#named-routes

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 2018-11-21
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 2017-10-16
    • 2016-09-15
    相关资源
    最近更新 更多