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
You can use the {labels.*} placeholders to grab a specific part of the hostname, where * is the index starting from the right, so {labels.0} is com, {labels.1} is example and {labels.2} is www.
So you could do something like:
@not-www not header_regexp Host ^www\.
redir @not-www https://www.{labels.1}{labels.0}{uri}