public function setURLFromServerVars()
    {
        if ($this->server->get('REQUEST_SCHEME'))
        {
            $base = $this->server['REQUEST_SCHEME'] . '://' . $this->server['SERVER_NAME'];
            $this->url = new URL($base . $this->server['REQUEST_URI']);
            $this->webroot = new URL($base . rtrim(dirname($this->server->get('SCRIPT_NAME')), '/') . '/');
        }
        else
        {
            $this->url = new URL($this->server->get('REQUEST_URI'));

            $host = $this->server['SERVER_NAME'] ?: $this->url->host;
            $port = $this->server['SERVER_PORT'] ?: $this->url->port;
            $this->webroot = !empty($host) ? new URL('http://' . $host) : new URL('/');
            if ($port && $port != 80)
                $this->webroot->port = $port;
        }
    }