private function rewriteBaseUrl($qsParams)
    {
        $url = null;

        if ($this->getBaseUrl()) {
            $baseUrlParts = explode('?', $this->getBaseUrl());
            $qsParser     = new \Zend\Stdlib\Parameters();

            $qsParser->fromArray($qsParams);

            if (count($baseUrlParts) > 1) {
                $qsParser->fromString($baseUrlParts[1]);
                $qsParams = array_merge($qsParser->toArray(), $qsParams);
                $qsParser->fromArray($qsParams);
            }

            $baseUrlParts[1] = $qsParser->toString();

            $url = implode('?', $baseUrlParts);
        }

        return $url;
    }