Laravel5 Redirect to external URL with params

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:37:05

问题


I've gone through the following page, but I can't find any examples at all: http://laravel.com/docs/5.1/responses#redirects.

I've tried the following:

return redirect()->away('http://bla.com');

This works, but as soon as you add params to it you get the following error message

PHP:

return redirect()->away('http://bla.com', ['bla' => 'bla']);

ERROR:

InvalidArgumentException in Response.php line 470: The HTTP status code "1" is not valid.


回答1:


Just add them to the string.

return redirect()->away('http://bla.com?bla=bla');

The second parameter for this function is the http status that should be sent to the visitor. So when you add an array this is parsed as a 1.




回答2:


If you want to get some variable ,you can use this

$kw='bla';
return redirect()->away('http://bla.com?bla='.$kw);


来源:https://stackoverflow.com/questions/34390850/laravel5-redirect-to-external-url-with-params

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!