Laravel5使用参数重定向到外部URL [英] Laravel5 Redirect to external URL with params
问题描述
我已经浏览了以下页面,但根本找不到任何示例: http://laravel.com/docs/5.1/responses#redirects .
I've gone through the following page, but I can't find any examples at all: http://laravel.com/docs/5.1/responses#redirects.
我尝试了以下操作:
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']);
错误:
InvalidArgumentException in Response.php line 470:
The HTTP status code "1" is not valid.
InvalidArgumentException in Response.php line 470:
The HTTP status code "1" is not valid.
推荐答案
只需将它们添加到字符串中即可.
Just add them to the string.
return redirect()->away('http://bla.com?bla=bla');
此功能的第二个参数是应发送给访问者的http状态.因此,当您添加数组时,它将被解析为1
.
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
.
这篇关于Laravel5使用参数重定向到外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!