you mean myhosts ? or myhost is an actual irule recognized command?
I do mean "myhost".
set myhost [class match -value [string tolower [HTTP::host]] equals myhosts]
set redirect 0
if { $myhost ne "" } {
set redirect 1
} else {
set myhost [HTTP::host]
}
If the class match returns a value and sets the myhost variable, then we simply set the redirect flag. Otherwise, we set the myhost variable to the actual host [HTTP::host]. In either case, the myhost variable contains a value in case the redirect flag is set and a redirect is issued.
Arguably option 2 will be the most difficult, given that your single data group may have MANY items to manage. Here's another option that combines options 1 and 3:
when HTTP_REQUEST {
set myhost [class match -value [string tolower [HTTP::host]] starts_with myhosts]
if { $myhost ne "" } {
HTTP::redirect "http://${myhost}[HTTP::uri]"
}
set myuri [class match -value [string tolower [HTTP::uri]] starts_with myuris]
if { $myuri ne "" } {
HTTP::redirect "http://[HTTP::host]${myuri}"
}
}
This will issue an initial redirect based on the host name, and then another based on the URI.