return elements, kw

def req_sub(info, request):
    return request.host.startswith('sub')
config.add_route('sub_only', '/', custom_predicates=(req_sub,),
    pregenerator=pregen)
config.add_route('foo', '/foo')
config.add_view(view, route_name - 'foo')

def view(request):
    return HTTPFound(request.route_url('sub_only'))
Multiple domains and subdomains on a single Pyramid instance