Forum Discussion

calvinm_388644's avatar
calvinm_388644
Icon for Nimbostratus rankNimbostratus
Apr 17, 2019

iRule URI Parameter Replacement

I'm working on finding a solution for being able to match a query parameter by string and essentially "find and replace" the parameter using an iRule? Something that would essentially look like the following:

Request In: https://yadayada.com/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&userID=OneRandomlyGeneratedString&host=vcenter222.dev.ops&locale=en-U

iRule processing...

Request Out: https://yadayada.com/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&userID=OneRandomlyGeneratedString&host=vcenter-server333.dev.ops&locale=en-U

Is there an example iRule for accomplishing something along these lines that works around there being a randomly generated parameter?

[edit] Added a parameter that is randomly generated

4 Replies

  • jitu's avatar
    jitu
    Icon for Nimbostratus rankNimbostratus

    You may try with below:

     

    when HTTP_REQUEST { if { ([string tolower [HTTP::uri]] equals "/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter222.dev.ops&locale=en-U") } { HTTP::redirect "https://[HTTP::host]/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter-server333.dev.ops&locale=en-U" return } }

     

    • calvinm_388644's avatar
      calvinm_388644
      Icon for Nimbostratus rankNimbostratus

      I apologize, I think I missed one of the problems I ran into with this. There is also a parameter in the URI that is randomly generated (i.e. &userID=sdfoajc391!90sjvdm3wdfs) so matching on a static URI wouldn't be possible.

       

  • You may try with below:

     

    when HTTP_REQUEST { if { ([string tolower [HTTP::uri]] equals "/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter222.dev.ops&locale=en-U") } { HTTP::redirect "https://[HTTP::host]/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter-server333.dev.ops&locale=en-U" return } }

     

    • calvinm_388644's avatar
      calvinm_388644
      Icon for Nimbostratus rankNimbostratus

      I apologize, I think I missed one of the problems I ran into with this. There is also a parameter in the URI that is randomly generated (i.e. &userID=sdfoajc391!90sjvdm3wdfs) so matching on a static URI wouldn't be possible.