Forum Discussion
Rory_Hewitt_F5_
May 01, 2015Cirrus
How can I remove a query parameter from a URL?
I'm trying to remove a query parameter from a URL, and I'm stuck... Basically, I may have 0-n parameters appended to a querystring. They will all have a similar name, starting with "Context_", e....
nitass
May 02, 2015Employee
shouldn't HTTP::uri be after foreach loop?
by the way, have you tried it on bigip? it seems okay here.
configuration
[root@ve11c:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
log local0. "---"
log local0. "before: [HTTP::uri]"
if {[HTTP::query] contains "Context_"} {
set newq ""
foreach param [split [HTTP::query] "&"] {
if { !($param starts_with "Context_") } {
if { $newq eq "" } {
append newq "?$param"
} else {
append newq "&$param"
}
}
}
if {$newq ne ""} {
HTTP::uri "[HTTP::path]$newq"
} else {
HTTP::uri [HTTP::path]
}
}
}
when HTTP_REQUEST priority 1000 {
log local0. "after: [HTTP::uri]"
}
}
/var/log/ltm
[root@ve11c:Active:In Sync] config tail -f /var/log/ltm
May 2 22:15:28 ve11c info tmm[5649]: Rule /Common/qux : ---
May 2 22:15:28 ve11c info tmm[5649]: Rule /Common/qux : before: /test
May 2 22:15:28 ve11c info tmm[5649]: Rule /Common/qux : after: /test
May 2 22:15:33 ve11c info tmm1[5649]: Rule /Common/qux : ---
May 2 22:15:33 ve11c info tmm1[5649]: Rule /Common/qux : before: /test?param1=value1
May 2 22:15:33 ve11c info tmm1[5649]: Rule /Common/qux : after: /test?param1=value1
May 2 22:15:40 ve11c info tmm[5649]: Rule /Common/qux : ---
May 2 22:15:40 ve11c info tmm[5649]: Rule /Common/qux : before: /test?param1=value1&Context_1=123
May 2 22:15:40 ve11c info tmm[5649]: Rule /Common/qux : after: /test?param1=value1
May 2 22:15:45 ve11c info tmm1[5649]: Rule /Common/qux : ---
May 2 22:15:45 ve11c info tmm1[5649]: Rule /Common/qux : before: /test?Context_1=123¶m1=value1
May 2 22:15:45 ve11c info tmm1[5649]: Rule /Common/qux : after: /test?param1=value1
May 2 22:15:50 ve11c info tmm[5649]: Rule /Common/qux : ---
May 2 22:15:50 ve11c info tmm[5649]: Rule /Common/qux : before: /test?Context_1=123¶m1=value1&Context_2=456¶m2=value2
May 2 22:15:50 ve11c info tmm[5649]: Rule /Common/qux : after: /test?param1=value1¶m2=value2
- Rory_Hewitt_F5_May 02, 2015CirrusHey @nitass, thanks for checking that. I suspect it could be just a Tclkit problem then...
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