This code will redirect :
- to
- net.staging.test1.com to net.staging.test2.com
when CLIENT_ACCEPTED {
set redirect_list [list ".test1.com" ".test2.com"]
}
when HTTP_REQUEST {
log loca0. "Request from host: [HTTP::host]"
if {[string tolower [HTTP::host]] ends_with [lindex $redirect_list 0]} {
set newHost [string map $redirect_list [HTTP::host]]
log local0. "Host contains test1.com, redirecting to https://$newHost[HTTP::uri]"
HTTP::respond 301 Location https://$newHost[HTTP::uri]
} else {
log local0. "Host: [HTTP::host] does not match the condition"
}
}