setBaseUrl($myBaseUrl); $subRequest = clone $request; // Removing the Host header. $subRequest->removeHeader('Host'); // Rewriting the url. $subRequest->setUrl($remoteUrl . $request->getPath()); $client = new Client(); // Sends the HTTP request to the server $response = $client->send($subRequest); // Sends the response back to the client that connected to the proxy. Sapi::sendResponse($response);