diff --git a/src/Proxy.php b/src/Proxy.php index 42d4bfb..3b5e3fa 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -72,7 +72,13 @@ public function to($target) // Check for subdirectory. if ($path = $target->getPath()) { - $uri = $uri->withPath(rtrim($path, '/') . '/' . ltrim($uri->getPath(), '/')); + $uriPath = ltrim($uri->getPath(), '/'); + $uri = $uri->withPath(rtrim($path, '/') . (!empty($uriPath) ? ('/' . ltrim($uri->getPath(), '/')) : '')); + } + + //check for query parameters. + if ($query = $target->getQuery()) { + $uri = $uri->withQuery($query); } $request = $this->request->withUri($uri);