Dynamic request(Host) conditions for redirect www

Hi Bernd,

What should I do if multiple hosts with multiple sub-domains?

Example:
Our application provides domain configuration for end users. End user points their A/AAAA to our address. Now we have a dynamic host requests.
Like, dev.com, dinesh.com, hopper.com and testing.com.

So Now what I need is need to check the incoming request.

# * means all incoming requests ( dev.com, dinesh.com, hopper.com and testing.com )
* {
if {host.sub_domain} is 'www'
redirect_to https://www.{host}{uri}
else
redirect_to https://{host}{uri}
end
}

This is not right code but I want like this instead of mention all our end user domains because we have 100+ different domains