Forum Discussion
John_43161
Nimbostratus
Oct 08, 2008Replace a query string variable value
This should be pretty straight forward but am having problems finding a way to change a query string variable value. basically I have an encoded url in the query string that I need to change to a different encoded url. I tried doing a string map on HTTP:uri, which didnt seem to work for values.
If anyone can help, would be most appreciated
Thanks!
- James_Quinby_46Historic F5 AccountCould you post a (sanitized, if necessary) copy of one of the URLs and what you need to change in it? A regex could probably do it, though there may be more efficient methods.
- John_43161
Nimbostratus
yeah the url is horrendous but the query variable in question isTARGET=-SM-http%3a%2f%2frbweb--dev%2egerbc%2erbcmtg%2ecom%2fcar%2f
TARGET=-SM-http%3a%2f%2f172%2e16%2e20%2e83%2fcar%2f
- James_Quinby_46Historic F5 AccountI've been playing around a little with this:
when HTTP_REQUEST { set TARGET [URI::query [HTTP::uri] "-SM-http%3a%2f%2f172%2e16%2e20%2e83%2fcar%2f"] }
- Give this a shot:
when HTTP_REQUEST { HTTP::uri [string map {"rbweb--dev%2egerbc%2erbcmtg%2ecom" "172%2e16%2e20%2e83"} [HTTP::uri]] }
http://myserver/foo/bar?TARGET=-SM-http%3a%2f%2frbweb--dev%2egerbc%2erbcmtg%2ecom%2fcar%2f
http://myserver/foo/bar?TARGET=-SM-http%3a%2f%2f172%2e16%2e20%2e83%2fcar%2f
- James_Quinby_46Historic F5 Accountstring map...beautiful. filing that one away for sure.
- John_43161
Nimbostratus
Thanks Joe. I tried the string map before but was using -nocase option.....would that make it not work for some reason? - hoolio
Cirrostratus
Hi John,when RULE_INIT { log local0. "[string map {find replace} "search in string: FIND replace"]" log local0. "[string map -nocase {find replace} "search in string: FIND replace"]" }
... set find "abc" set replace "xyz" log local0. "[string map {$find $replace} "search in string: abc"]" ...
set find "abc" set replace "xyz" log local0. "[string map "$find $replace" "search in string: abc"]"
- hoolio
Cirrostratus
Ha... actually I should read the posts I'm referencing. Joe stated in that post that the -nocase flag isn't supported for any command. I think this has changed in recent versions or was only true for the switch command. It works for string map in 9.4.5 and probably earlier versions (Click here - 9.1.0). - John_43161
Nimbostratus
btw, thanks for all the help guys appreciate it.
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