Forum Discussion
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
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 } }
- calvinm_388644
Nimbostratus
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_106210
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 } }
- calvinm_388644
Nimbostratus
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com