public static function handleUnknownHost(URL $webroot, URL $request, array $sites, Dictionary $cfg)
    {
        // Determine behaviour on unknown host
        $on_unknown = strtoupper($cfg->dget('unknown_host_policy', "IGNORE"));
        $best_matching = self::findBestMatching($webroot, $sites);

        if ($on_unknown === "ERROR" || ($best_matching === null && $on_unknown === "REDIRECT"))
            return null;

        if ($on_unknown === "REDIRECT")
        {
            $redir = $best_matching->URL($request->path);
            return $redir;
        }

        // Generate a proper VirtualHost on the fly
        $url = new URL($webroot);
        $url->fragment = null;
        $url->query = null;
        $lang = $cfg->dget('default_language', 'en');
        $vhost = new VirtualHost($url, $lang);

        // Add the new virtualhost to a site.
        if ($best_matching === null)
        {
            // If no site has been defined, create a new one
            $site = new Site();
            $site->addVirtualHost($vhost);
        }
        else
            $best_matching->getSite()->addVirtualHost($vhost);

        return $vhost;
    }
public static function handleUnknownHost(URL $webroot, URL $request, array $sites, Dictionary $cfg)
    {
        // Determine behaviour on unknown host
        $on_unknown = strtoupper($cfg->dget('unknown_host_policy', "IGNORE"));
        $best_matching = self::findBestMatching($webroot, $sites);

        if ($on_unknown === "ERROR" || ($best_matching === null && $on_unknown === "REDIRECT"))
            return null;

        if ($on_unknown === "REDIRECT")
        {
            $redir = $best_matching->URL($request->path);
            return $redir;
        }

        // Generate a proper VirtualHost on the fly
        $url = new URL($webroot);
        $url->fragment = null;
        $url->query = null;
        $lang = $cfg->dget('default_language', 'en');
        $vhost = new VirtualHost($url, $lang);

        // Add the new virtualhost to a site.
        if ($best_matching === null)
        {
            // If no site has been defined, create a new one
            $site = new Site();
            $site->addVirtualHost($vhost);
        }
        else
            $best_matching->getSite()->addVirtualHost($vhost);

        return $vhost;
    }
public static function handleUnknownHost ( URL $ webroot , URL $ request , array $ sites , Dictionary $ cfg ) { // Determine behaviour on unknown host $ on_unknown = strtoupper ( $ cfg -> dget ( 'unknown_host_policy' , "IGNORE" ) ) ; $ best_matching = self :: findBestMatching ( $ webroot , $ sites ) ; if ( $ on_unknown === "ERROR" || ( $ best_matching === null && $ on_unknown === "REDIRECT" ) ) return null ; if ( $ on_unknown === "REDIRECT" ) { $ redir = $ best_matching -> URL ( $ request -> path ) ; return $ redir ; } // Generate a proper VirtualHost on the fly $ url = new URL ( $ webroot ) ; $ url -> fragment = null ; $ url -> query = null ; $ lang = $ cfg -> dget ( 'default_language' , 'en' ) ; $ vhost = new VirtualHost ( $ url , $ lang ) ; // Add the new virtualhost to a site. if ( $ best_matching === null ) { // If no site has been defined, create a new one $ site = new Site ( ) ; $ site -> addVirtualHost ( $ vhost ) ; } else $ best_matching -> getSite ( ) -> addVirtualHost ( $ vhost ) ; return $ vhost ; }
Determine what to do when a request was made to an unknown host.

The default configuration is IGNORE, which means that a new vhost will be
generated on the fly and attached to the site of the closest matching VirtualHost.
If no site is configured either, a new Site named 'defaul't is created and the new
VirtualHost is attached to that site. This makes configuration non-required for
simple sites with one site and one hostname.

@param URL $webroot The webroot where a request was made
@param URL $url The URL that was requested
@param array $sites The configured sites
@param Dictionary $cfg The configuration to get the policy from
@return mixed One of:
* null: if the policy is to error out on unknown hosts
* URI: if the policy is to redirect to the closest matching host
* VirtualHost: if the policy is to ignore / accept unknown hosts
Determine what to do when a request was made to an unknown host .