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;
    }
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;
    }
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 ; }
Find out which VirtualHost was targeted and redirect if configuration
requests so.

@return Dispatcher Provides fluent interface
@throws Throwable Various exceptions depending on the configuration -
Error(404) when the configuration says to prohibit use of
unknown hosts, RedirectRequest when a redirect to a different
host is requested, RuntimeException when unexpected things happen.
Find out which VirtualHost was targeted and redirect if configuration requests so .