Phil_Lawrence_7
Nov 11, 2011Nimbostratus
Irule to redirect based on host and uri - lowercase issue
Hi
We are using BigIP v9.x
Im new to irules and I have done some searching on this forum and from the examples I've found ive managed to write the following (which works)
when HTTP_REQUEST { if {[HTTP::host] == "wibble.com" and [HTTP::uri] contains "&lang=Anon&country=Anon"}{
if {[scan [HTTP::uri] "/livelink/livelink.exe?func=ll&objid=%d&objAction=%s" dnum action] == 2} {
HTTP::redirect "http://wibble.com/otcs/livelink.exe?func=LL.login&username=Myuserid&password=XYZ&NextURL=%2Fotcs%2Flivelink%2Eexe%3Ffunc%3Dll%26objId%3D$dnum%26objAction%3D$action"
}
}
}
the logic behind this is .....
original url
http://wibble.com/livelink/livelink...untry=Anon
redirect all trafffic from http://wibble.com that has "&lang=Anon&country=Anon" in the url
Put the numeric value after objid= into a variable dnum and the word after objaction and before the & into a variable called action
this works, however the action variable contains the rest of the URI, which whilst not ideal is working for us.
I have found an error where if someone puts the url in a different case, it fails ... so I've been trying to use the tolower command, but I get an error saying that tolower is not a valid maths function
when HTTP_REQUEST {
if {tolower([HTTP::host]) == "wibble.com" and tolower([HTTP::uri]) contains "&lang=anon&country=anon"}{
if {[scan [HTTP::uri] "/livelink/livelink.exe?func=ll&objid=%d&objAction=%s" dnum action] == 2} {
HTTP::redirect "http://wibble.com/otcs/livelink.exe?func=LL.login&username=Myusername&password=XYZ&NextURL=%2Fotcs%2Flivelink%2Eexe%3Ffunc%3Dll%26objId%3D$dnum%26objAction%3D$action" } } }
once this is working I can then do the next section which is dependant on if the objaction in the url = open, do one redirect, else do another ... however this now seems very long and a little unweildy
when HTTP_REQUEST {
if {tolower([HTTP::host]) == "ecm.express.tnt" and tolower([HTTP::uri]) contains "&lang=anon&country=anon"}{
if {tolower([HTTP::uri]) contains "objaction=open"}{
if {[scan [HTTP::uri] "/livelink/livelink.exe?func=ll&objid=%d&objAction=%s" dnum action] == 2} {
HTTP::redirect "http://ecm.express.tnt/otcs/livelink.exe?func=LL.login&username=Anonymous&password=&NextURL=%2Fotcs%2Flivelink%2Eexe%3Ffunc%3Ddoc%2Efetch%26nodeid%3D$dnum"
}
} else if {[scan [HTTP::uri] "/livelink/livelink.exe?func=ll&objid=%d&objAction=%s" dnum action] == 2} {
HTTP::redirect "http://ecm.express.tnt/otcs/livelink.exe?func=LL.login&username=Anonymous&password=&NextURL=%2Fotcs%2Flivelink%2Eexe%3Ffunc%3Dll%26objId%3D$dnum%26objAction%3D$action"
}
}
}
any advice would be welcomed
Thanks in Advance
Phil