Marcus_10406
Oct 17, 2016Nimbostratus
irule to replace any .asp to be .aspx in uri
hi there,
our APPDEV team requesting a uri replacement to be done on my LTM to realize following:
for any incoming URL, replace .asp by .aspx. for example: 123.abc.com/xxx.asp will be replaced as www.abc.com/xxx.aspx 123.abc.com/xxx.asp?xxxxxxxx to be replaced as www.abc.com/xxx.aspx?xxxxxxxx
to meet this requirement, I need to check the following charactor of '.asp' is not 'x'. anyone has experience on how to irule it?
here is the one I did:
when HTTP_REQUEST {
switch -glob [HTTP::host][HTTP::uri] {
"wm.456.abc.com/*" {
HTTP::redirect "https://teams.abc.com[HTTP::uri]"
}
"123.abc.com/*" {
if { [HTTP::uri] contains ".aspx"} {
HTTP::redirect "https://www.abc.com[HTTP::uri]"
} elseif {[HTTP::uri] contains ".asp"} {
set uri [string map {".asp" ".aspx"}[HTTP::uri]]
HTTP::redirect "https://www.abc.com$uri"
} else {
HTTP::redirect "https://knowledge.cibc.com[HTTP::uri]"
}
}
default {
pool /PROD/po_abc
}
}
}