Forum Discussion

gauthj1_343742's avatar
Icon for Nimbostratus rankNimbostratus
Oct 19, 2018

partial uri replace and keep the query

Hello, First time poster, and running into something more advanced than I am at this time.


Trying to search and finding many variables with mixed results on my output. Currently running 11.5.4 with HF2.


What we want to happen, is if the uri starts with /rdcadfsrnd/faces/logout?_adf , then replace that with /ocsso/logout? and include the rest of the generated query.


Here is an example iRule we have tried.


when HTTP_REQUEST { if { ([HTTP::host] starts_with "") and ([string tolower [HTTP::uri]] starts_with "/rdcadfsrnd/faces/logout\?_adf") } { HTTP::redirect "[string map {/rdcadfsrnd/faces/logout /ocsso/logout} [string tolower [HTTP::query]]]" } }


Here is another that I have tried: when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/rdcadfsrnd/faces/logout\?_adf"}{ HTTP::redirect " [string[HTTP::query]]" } }


Capturing the header results always seemed to be different... getting either a looping redirect, or only getting the path, ignoring the host+ ? and the query all together. Another time all I was getting was the query, ignoring everything up to and including the ?.


I have a feeling I am making this more complicated than it needs to be, although the logic is eluding me.


I am asking for some advise on this, and if you're feeling generous, maybe a working example?


I have been decent with figuring some of these out before, although this one is trouble for me, and spent a few hours searching and testing with no forward progress.


Thanks to all in advance! Appreciated. Jason


1 Reply

  • Hello, Maybe this way?

    when HTTP_REQUEST {
        if { [HTTP::host] eq "" && [string tolower [HTTP::uri]] starts_with "/rdcadfsrnd/faces/logout?_adf" } { 
            HTTP::redirect "/ocsso/logout?[string range [HTTP::uri] 29 end]"