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.
Could 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.
Of course, if you need to expand this, you could put the relevant URL’s in a class and do a lookup and then a replace based on a match in the class but you only specified that you had one url to change.
I know the nocase flag isn’t supported with switch statements as Joe pointed out in this post (Click here). But -nocase should work for string map:
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"]"
}
Log output:
Rule : search in string: FIND replace
Rule : search in string: replace replace
Maybe it was down to using a variable with curly braces? This would not work because the curly braces force a literal interpretation of the search/replace fields:
...
set find "abc"
set replace "xyz"
log local0. "[string map {$find $replace} "search in string: abc"]"
...
Log output:
Rule : search in string: abc
You could use quotes instead to allow for variable expansion:
set find "abc"
set replace "xyz"
log local0. "[string map "$find $replace" "search in string: abc"]"
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).
If you test with the -nocase option, do you get a TCL error in /var/log/ltm either when you try to save the rule or when you hit that portion of the code in a request?