Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Redirect/URI change based on numeric variable

I've had what I think is an interesting customer request. Although this may be a simple redirect it seems more complex and haven't been able to put all the pieces together. The customer has a URL:

https://x.123.com/123.asp?r=&p=https%3A//site.com/&llactid=34567&llnocookies=undefined

There is a distinct ID in URIs, 34567 in this case, and we wish all IDs greater than 29999 but not equal to 30484 to be altered and redirected to:

https://y.abc.com/trackalyze.asp?r=&p=https%3A//site.com/&llactid=34567&llnocookies=undefined

in order to route/balance this traffic as it hits BigIP. All IDs below that threshold would remain unchanged. Is a policy best for this or can this be done syntactically in an iRule? I've been trying simple if-then [HTTP::uri] logic but not sure how to account for the numeric variable and hitting deadends. I guess anything can be done. Many thanks!

x <= 29999 including 30484 go to site A/uri

x > 29999 /= 30484 go to site B/uri

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

This should work:

when HTTP_REQUEST {
    if { ([HTTP::host] eq "x.123.com") && [HTTP::uri] starts_with "/123.asp" } {
        set llactid [URI::query [HTTP::uri] "llactid"]
        if { ($llactid ne 30484) && $llactid > 29999 } {
            HTTP::redirect "https://y.abc.com/trackalyze.asp?r=&p=https%3A//site.com/&llactid=$llactid&llnocookies=undefined"
        }
    }
}
0
Comments on this Answer
Comment made 09-May-2018 by Z 2

Super! setting the variable is the syntax I am missing. I think this looks good; have to test this and will advise.

0
Comment made 11-May-2018 by Z 2

Niels many thanks! This works nicely!

0
Comment made 11-May-2018 by Niels van Sluis 2744

You’re welcome. Good to hear it works!

0
Comment made 13-May-2018 by Stanislas Piron 10640

Instead of [HTTP::uri] starts_with "/123.asp" condition, I recommend to use [HTTP::path] equals "/123.asp"

[HTTP::path]returns the URI part before ? character

0