【发布时间】: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 的全新安装中不会发生这种情况。
有人想出办法吗?
谢谢大家!
【问题讨论】:
-
设置 Cookie:2325 年 7 月 30 日? :) 重定向到命名路由 laravel.com/docs/5.8/redirects