重定向到页面不工作?
问题描述:
我有这样的功能:重定向到页面不工作?
public function index(Request $request){
$email = $request->email;
$password = $request->password;
if (!$email || !$password) {return redirect()->back();}
if (Auth::attempt(['email' => $email, 'password' => $password])) {
// Authentication passed...
$this->loggedUser = Auth::user();
if($this->loggedUser){
return redirect('http://localhost:3000/home');
}
}
return redirect()->back()->withInput()->withErrorMessage('Uneseni podaci nisu ispravni.');
}
我想要的是,如果他登录到用户重定向,但没有happend。当我打开我的浏览器预览它只是说
Redirecting to http://localhost:3000/home
但它不重定向我。任何建议?
当我手动输入出现
答
更改重定向地址:如果你想重定向到一个绝对的URL,你可以试试这个
return redirect('home');
+0
再次没有发生,但在预览它说: 重定向到http:// localhost:8000/home。这就是它....在我的浏览器路由是http:// localhost:3000。 – None
答
:
return redirect(url('http://localhost:8000/home'));
或者你可以试试这个相对网址:
return redirect('/home'));
第一个不好,因为如果你的域(http://localhost:8000)是 改变了,那么你所有的链接都需要改变。所以第二个 的做法比较好。
尝试'重定向(“/家庭”)' –
同样的问题..它只是说redirectin预览,但什么也没有发生 – None
这个方法做工精细的其他重定向? –