adamj
adamj

Reputation: 4782

Laravel5 Redirect to external URL with params

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.

Upvotes: 1

Views: 6199

Answers (3)

marijn
marijn

Reputation: 21

Unfortunately, I didn't find anything better than the following code;

 $url = $redirectUrl . '?' . http_build_query($array);
 return Redirect::away($url);

Upvotes: 0

C.ryudo
C.ryudo

Reputation: 65

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

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

Upvotes: 1

Jerodev
Jerodev

Reputation: 33186

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.

Upvotes: 7

Related Questions