Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

iRule URI Parameter Replacement

calvinm_388644
Nimbostratus
Nimbostratus

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 4

jitu_106210
Nimbostratus
Nimbostratus

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 } }

 

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.

 

jitu
Nimbostratus
Nimbostratus

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 } }

 

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.