Laravel:从控制器重定向到特定的 url
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46879464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: redirecting to a specific url, from controller
提问by Alfredo Soler
I'm having troubles to just redirect to a url from a controller.
我无法从控制器重定向到 url。
This is my trigger:
这是我的触发器:
<form method="POST" action="{{ url('creategroup") }}">
Then, this is the catcher:
然后,这是捕手:
Route::post('/creategroup', 'GroupController@store');
And finally, this is my method:
最后,这是我的方法:
public function store(Request $request) {
/* bla bla bla */
return Redirect::to('/users/'.$request->id.'/groups/');
}
But it doesn't work, the url just stops in localhost/creategroup and it shows a page that say that the page has expired, and it doesn't redirect to any place. Help please.
但它不起作用,该 url 只是在 localhost/creategroup 中停止,它显示一个页面,说该页面已过期,并且它不会重定向到任何地方。请帮忙。
回答by Lloople
回答by utdev
This could happen due to the first backslash, try following:
这可能由于第一个反斜杠而发生,请尝试以下操作:
return redirect('users/'.$request->id.'/groups');