Need help redirecting hundreds of host:uris to differentHOST:differentURI using datagroup and irule
Hi All.
I am using a BIG IP LTM v15.1.0.4
We have a file of 300 redirects that need to be handled by the F5 for one specific VIP. Its basically ONEHOST:ONEURI to ANOTHERHOST:ANOTHERURI. I have been unsuccessful in getting a datagroup and irule working to handle these redirects.
i have read through several threads and watched several videos but none of what I have learned and put in place is working. I figured out how to import the file of redirects to create the datagroup. However the irule does not seem to match anything.
As a troubleshooting step, I created a string datagroup using the GUI with one "string 😆 value" combination, but I get the same result (so Im thinking the problem is my irule). Here are two examples of what I put into the irule (niether worked):
when HTTP_REQUEST {
if {[set redir_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals datagroup]] ne ""}{
HTTP::respond [getfield redir_url " " 1] Location [getfield redir_url " " 2]
}
}
when HTTP_REQUEST {
if {[set redir_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals datagroup]] ne "" }{
HTTP::redirect $redir_url
}
}
I also tried changing "equals" to "contains" and also "like" but that didn't help either.
In my datagroup, I tried "https://mycompany.com/linkA" := "https://anothercompany.com/newlink". I tried with and without the "https://", but cant seem to get a match
I'm hoping I have a simple syntax error that someone can help me with. Any advice is appreciated.
I dont see any syntax issue. But I see problem in your data group.
In my datagroup, I tried "https://mycompany.com/linkA" := "https://anothercompany.com/newlink". I tried with and without the "https://", but cant seem to get a match
I see you have put "https://mycompany.com/linkA", where the uri linkA is having A as caps.
So the Irule is converting everything to small case & when it does, it looks for record ""https://mycompany.com/linka" but it can't find one. So it wont redirect.
If you are doing string to lower in your irule, make sure you add your datagroup records in smaller case too.
This is a common mistake to ignore. I've done multiple times.
Please keep us posted & mark the thread as closed if it answers.