lib/redirectHost.js
function createHandler(to, except, pathFunc, protocol) {
    return function(req, res, next) {
        var host = req.hostname || '';
        var url = req.url;

        if (host in except) {
            next();
        } else {
            var target = new URIjs(pathFunc(host, url))
              .host(to)
              .protocol(protocol || '')
              .href();

            res.redirect(301, target);
        }
    };
}
function createHandler(to, except, pathFunc, protocol) {
    return function(req, res, next) {
        var host = req.hostname || '';
        var url = req.url;

        if (host in except) {
            next();
        } else {
            var target = new URIjs(pathFunc(host, url))
              .host(to)
              .protocol(protocol || '')
              .href();

            res.redirect(301, target);
        }
    };
}
function createHandler ( to , except , pathFunc , protocol ) { return function ( req , res , next ) { var host = req . hostname || '' ; var url = req . url ; if ( host in except ) { next ( ) ; } else { var target = new URIjs ( pathFunc ( host , url ) ) . host ( to ) . protocol ( protocol || '' ) . href ( ) ; res . redirect ( 301 , target ) ; } } ; }
Creates the middleware to handle the redirect

@param {String} to
@param {Array} except
@return {Function} middleware function(req, res, next)
@api private
Creates the middleware to handle the redirect