Forum Discussion
Kai_Wilke
MVP
Jan 29, 2016Hi Cody,
you may try the performance optimized snippet below. It would require just a single data group query to check for existence and to retrieve the location value...
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } then {
if { [set location [class match -value [string range [HTTP::host] 4 end] eq group_80_host_redirect]] ne "" } then {
HTTP::redirect $location
return
}
} else {
if { [set location [class match -value [HTTP::host] eq group_80_host_redirect]] ne "" } then {
HTTP::redirect $location
return
}
}
HTTP::redirect "https://www.company.com/unknown_hostname/error.html?host=[URI::encode [HTTP::host]]"
}
Cheers, Kai