public function rootRelative($baseUrl)
    {
        $url = $this->url;

        $parsedBaseUrl = parse_url($baseUrl) + array(
                'path' => '',
            );
        if (!isset($parsedBaseUrl['scheme'], $parsedBaseUrl['host'])) {
            throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.');
        }

        if (empty($url)) {
            return $parsedBaseUrl['path'] . (isset($parsedBaseUrl['query']) ? '?' . $parsedBaseUrl['query'] : '');
        }

        $parsedUrl = parse_url($url) + array(
                'path' => '/',
            );
        if (substr($url, 0, 1) == '?') {
            return $parsedBaseUrl['path'] . $url;
        }

        if (substr($url, 0, 3) == '../') {
            $pathParts = explode('/', $parsedBaseUrl['path']);
            array_pop($pathParts);

            while (substr($url, 0, 3) == '../') {
                array_pop($pathParts);
                $url = substr($url, 3);
            }

            return implode('/', $pathParts) . '/' . $url;
        }

        return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');
    }