Reputation: 470
I'm trying to redirect my site to an external website with parameters. However when I do this, I get an Error Exception saying "Header may not contain more than a single header, new line detected". This would be my redirection code;
return Redirect::to($redirectUrl)->with(['ord_date' => $dueDate, 'ord_totalamt' => $cart_total, 'ord_gstamt' => 0.00, 'ord_shipname' => $user['name'],'ord_mercref' => $ord_mercref, 'ord_mercID' => $merchantid, 'ord_returnURL' => 'http://local.site.com/order/status', 'merchant_hashvalue' => $key]);
Note that I've tried using Redirect::away
as well, and it results in the same error.
What am I doing wrong here?
Edit #1;
My $redirecturl
is as such; $redirecturl = 'https://myurl.com"
so it is in one line.
Upvotes: 0
Views: 82
Reputation: 17216
You should build the data into the $redirectUrl
yourself instead of using with
.
$query = http_build_query([
'ord_date' => $dueDate,
'ord_totalamt' => $cart_total,
'ord_gstamt' => 0.00,
'ord_shipname' => $user['name'],
'ord_mercref' => $ord_mercref,
'ord_mercID' => $merchantid,
'ord_returnURL' => 'http://local.site.com/order/status',
'merchant_hashvalue' => $key
])
$formattedRedirectUrl = preg_replace('/[ \t]+/', ' ', preg_replace('/[\r\n]+/', "\n", $redirectUrl);
return Redirect::to($formattedRedirectUrl.'?'.$query);
Upvotes: 2