Skip to content

URL::to and url() question regarding the query string #45413

Answered by hafezdivandari
EmranMR asked this question in Q&A
Discussion options

You must be logged in to vote

The url helper function and URL facade are for generating URLs within your application (internal) you may use PHP http_build_query function instead:

$url = 'https://www.google.com?'.http_build_query(['bar' => 'baz']); // https://www.google.com?bar=baz

additionally, if you want to redirect to an external domain you may use:

return redirect()->away('https://www.google.com?'.http_build_query(['bar' => 'baz']));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@EmranMR
Comment options

Answer selected by EmranMR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants