Hello Everyone,
Quick question regarding a re-direct irule. so we have a requirement to redirect example.com and exampleabc.com to examplexyz.com and this works via the following irule but if append a dot after .com then it doesn’t redirect… so example.com. doesn’t redirect. we also need it to be a 301 re-direct also we can not use generic host as this is a shared VIP. Any thoughts?
when HTTP_REQUEST { set r_host [HTTP::header “Host”] switch $r_host { "; - "; -
HTTP::respond 301 "Location" "https://www.examplexyz.com"
}
} }
when HTTP_REQUEST { set r_host [HTTP::header “Host”]
switch $r_host { ";; - ";; - HTTP::respond 301 “Location” "; }
} }
Hi,
switch command evaluate exact value.
example.com
us not the same string than
example.com.
when HTTP_REQUEST {
switch -- [HTTP::host] {
"www.example.com" -
"www.example.com." -
"www.exampleabc.com" -
"www.exampleabc.com." {
HTTP::respond 301 "Location" "https://www.examplexyz.com"
}
}
}
you can also use glob option to use wildcard
when HTTP_REQUEST {
switch -glob -- [HTTP::host] {
"www.example.com?" -
"www.exampleabc.com?" {
HTTP::respond 301 "Location" "https://www.examplexyz.com"
}
}
}