Forum Discussion
Rajesh_A_142089
Apr 08, 2014Nimbostratus
Remove part of querystring
I want to remove specific key=value pair from the querystring if present
-If my uri is /myuri?mykey=myvalue or /myuri?otherkey=othervalue&mykey=myvalue -I want to rewrite the uri such that I rem...
- Apr 09, 2014
Just one approach;-
when HTTP_REQUEST { if {[URI::query [HTTP::uri]] contains "mykey="} { set newq "" foreach param [split [URI::query [HTTP::uri]] "&"] { if {!($param starts_with "mykey=")} { Build up new query parameter string append newq $param } Add new query portion to path HTTP::uri "[HTTP::path]$newq" } }
Rajesh_A_142089
Jun 06, 2014Nimbostratus
For everyone benefit, here I wanted to share the final version. From the above script we failed to put & in between each key=value pairs. Here is the working script:
when HTTP_REQUEST { set newq ""
foreach param [split [URI::query [HTTP::uri]] "&"] { if {!($param contains "mykey=" )} { if {$newq eq ""} { append newq $param } else { append newq "&$param" } } } Add new query portion to path if {$newq ne ""} { HTTP::uri "[HTTP::path]?$newq" } else { HTTP::uri [HTTP::path] } }
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