Forum Discussion
Moinul_Rony
Altostratus
May 15, 2014How to destroy and replace a URI query value ?
Hi,
I am trying to figure out how I can replace a URI query value.
For example for this we will select the URL based on the HTTP:host
Incoming URL pattern
https://host/URI?
http...
nitass_89166
Noctilucent
May 19, 2014e.g.
config
[root@ve11a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
set q [URI::query [HTTP::uri] query]
log local0. "q = $q"
if { $q eq "A" } {
log local0. "origin uri = [HTTP::uri]"
HTTP::uri [string map "query=$q query=B" [HTTP::uri]]
log local0. "new uri = [HTTP::uri]"
}
}
}
/var/log/ltm
[root@ve11a:Active:In Sync] config tail -f /var/log/ltm
May 18 21:32:58 ve11a info tmm[14715]: Rule /Common/qux : q = A
May 18 21:32:58 ve11a info tmm[14715]: Rule /Common/qux : origin uri = /URI?query=A&other=somethingelse
May 18 21:32:58 ve11a info tmm[14715]: Rule /Common/qux : new uri = /URI?query=B&other=somethingelse
Moinul_Rony
Altostratus
May 27, 2014Thanks nitass, that works perfectly.
But now I have a slightly different requirement
matching on the incoming hostname (red.x.com) I would want to add a value such as code=red and replace anything else with code=red
example:
Case 1:
code=yellow gets replaced with code=red
https://red.x.com/test/find.jsp?dodgy=bla&class=XY&code=yellow&run=Y&state=QLD should change to
https://red.x.com/test/find.jsp?dodgy=bla&class=XY&code=red&run=Y&state=QLD
code=red value not present -> add to the end of the URI
https://red.x.com/test/find.jsp?dodgy=bla&class=XY&run=Y&state=QLD should change to
https://red.x.com/test/find.jsp?dodgy=bla&class=XY&run=Y&state=QLD&code=red
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects