How to do a RedirectResponse with a destination query parameter? This works:

$redirectURL = '/cart/add/p2';
return new RedirectResponse(base_path().$redirectURL);


The problem is, I want this:

$redirectURL = '/cart/add/p2?destination=somewhere';


The moment I added destination=somewhere, I get this error:

InvalidArgumentException: The internal path component 'http://localhost/XXXX/public_html/XXXX/XXXX' is invalid. Its path component must have a leading slash, e.g. internal:/foo. in Drupal\Core\Url::fromInternalUri() (line 404 of C:\ampps\www\XXXX\public_html\core\lib\Drupal\Core\Url.php).


However, if I do this:

$redirectURL = '/cart/add/p2?SOMETHING_ELSE=somewhere';


Then it works. In other words, it specifically breaks if I add "destination=somewhere".

Why would it be breaking on this and how do I get around it? I.e. How do I redirect to a URL with destination=somewhere in the query string.

FYI: If I can get this to work, I can use "Cart Links" to add stuff to a cart and redirect the user at the same time, making my live a lot easier.
Better use a route, so that the path processing in Drupal can do its job. 
If custom.cart_add is the route to /cart/add/{page}, this returns a redirect response with a destination query parameter from a controller:

  return $this-&gt;redirect(
    'custom.cart_add',
    ['page' =&gt; 'p2'],
    [
      'query' =&gt; ['destination' =&gt; 'somewhere'],
      'absolute' =&gt; TRUE,
    ]
  );