I am trying to do a redirect with query parameters, using the redirect()
helper:
$link = 'https://example.com' . '?key1=value1&key2=value2';
return redirect()->to($link);
The problem is that when the $link
is passed to the to()
method Laravel removes the question mark leading the query string, so it turns this:
https://example.com?key1=value1&key2=value2
into this:
https://example.comkey1=value1&key2=value2
(again, notice the missing ?
in the final link).
How do I make a redirect with query params appended to a custom URL?
Redirect with parameters to a specific page/folder/subfolder You can also configure a URL redirect record that includes folders/subfolders both of your source and destination URLs.
Any word after the question mark (?) in a URL is considered to be a parameter which can hold values. The value for the corresponding parameter is given after the symbol "equals" (=). Multiple parameters can be passed through the URL by separating them with multiple "&".
To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect after.
return redirect($link);
return redirect()->route('route_name',['key'=> $value]);
Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With