public function determineVirtualHost()
    {
        // Determine the proper VirtualHost
        $cfg = $this->config->getSection('site');
        $vhost = self::findVirtualHost($this->request->webroot, $this->sites);
        if ($vhost === null)
        {
            $result = $this->handleUnknownHost($this->request->webroot, $this->request->url, $this->sites, $cfg);
            
            // Handle according to the outcome
            if ($result === null)
                throw new HTTPError(404, "Not found: " . $this->url);

            if ($result instanceof URL)
                throw new RedirectRequest($result, 301);

            if ($result instanceof VirtualHost)
            {
                $vhost = $result;
                $site = $vhost->getSite();
                if (isset($this->sites[$site->getName()]))
                    $this->sites[$site->getName()] = $site;
            }
            else
                throw \RuntimeException("Unexpected response from handleUnknownWebsite");
        }
        else
        {
            // Check if the VirtualHost we matched wants to redirect somewhere else
            $target = $vhost->getRedirect($this->request->url);
            if ($target)
                throw new RedirectRequest($target, 301);
            
        }
        $this->setVirtualHost($vhost);
        return $this;
    }