04-Feb-2021 10:55
disclaimer, I do not know iRules for anything......but I have been asked to create on for the following.
here are my requirements, iRule to redirect traffic .
1. if this = https://abc.help.com/support/case/v2/WebCase respond to here = sa.abcs.help.com
2. if this = https://abc.help.com/HBServices/abc/v1/asset/$uri respond to here - hb.abcs.help.com
3. if this = https://abc.help.com/support/assetinfo/v4/getassetwarranty/$uri respondwith 404
4. if this = https://abc.help.com/$uri respond to here = abc2.us.help.com
Here is what I tried .
when HTTP_REQUEST {
if {
([string tolower [HTTP::host]] equals "abc.help.com") &&
([HTTP::uri] contains "/support/case/v2/WebCase")
}
{
HTTP::redirect "https://sa.abcs.help.com[HTTP::uri]"
}
}
elseif {
([string tolower [HTTP::host]] equals "abc.help.com") &&
([HTTP::uri] contains "/hbserial/abc/v1/asset/$uri")
}
{
HTTP::redirect "https://hb.abcs.help.com[HTTP::uri]"
}
}
elseif {
([string tolower [HTTP::host]] equals "abc.help.com") &&
([HTTP::uri] contains "/support/assetinfo/v4/getassetwarranty/$uri")
}
{
HTTP::respond "404 [HTTP::uri]"
}
}
elseif {
([string tolower [HTTP::host]] equals "abc.help.com") &&
([HTTP::uri] contains "/$uri")
}
{
HTTP::redirect "https://abc2.us.help.com[HTTP::uri]"
}
}
04-Feb-2021
12:40
- last edited on
04-Jun-2023
21:04
by
JimmyPackets
Hi MikeyG,
when HTTP_REQUEST {
if { [HTTP::host] equals "abc.help.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/support/case/v2/webcase*" { HTTP::redirect https://sa.abcs.help.com[HTTP::uri] }
"/hbservices/abc/v1/asset*" { HTTP::redirect https://hb.abcs.help.com[HTTP::uri] }
"/support/assetinfo/v4/getassetwarranty*" { HTTP::respond 404 content "404 Page Not Found" }
default { HTTP::redirect https://abc2.us.help.com[HTTP::uri] }
}
}
}
05-Feb-2021 05:15
Thank you, i am getting better but I just do not do them very often.