Forum Discussion
Gaelle_31283
Nimbostratus
Oct 01, 2008Rewriting uri
Hi,
I'm a newbie and I want to rewrite a uri.
if uri contains uid
then I rewrite uri
else I do nothing.
For example :
rtsp://ip?a=123&k=456&uid=toto&h=789 becomes rtsp://ip?hxs=1&uid=toto&a=123&k=456&h=789
uid can be anywhere in uri: just after ? or be last parameter or be between parameters. When rewriting uri, hxs=1&uid=toto must be immediately after ? but I have to keep other parameters. We don't know which are the other parameters.
I want to get beginning of uri to ? (I manage to do it), get uid (I manage too), and then get parameters before uid if existing (I don't manage) and get parameters after uid if existing (I don't manage either). When I get all of that I can concatenate beginning of uri+?+hxs=1&uid=toto+parameters before uid+parameters after uid.
Another solution is to deplace uid and then insert hxs=1 before it but I try to use string replace without success
Can anyone see a solution to that problem?
Thanks.
3 Replies
Sort By
- hoolio
Cirrostratus
Hi Gaelle, - hoolio
Cirrostratus
Sorry, I thought you wanted to strip out the uid parameter and its value if set. I reread your first post and think you want to move uid and its value to the front of the query string and then prepend hxs=1. Here is an example which avoids regexes. Maybe someone has a more efficient method?when RULE_INIT { Set a couple of test query strings set source {a=123&k=456&uid=toto&h=789} set source {uid=toto&a=123&k=456&h=789} set source {a=123&k=456&h=789&uid=toto} Split the string into a list on the delimiter & log local0. "\[split \$source\ &]: [split $source &]" Create a new query string set new_query_string "" Loop through the list and create a new string of parameters and values foreach param_value_pair [split $source &] { log local0. "\$param_value_pair: $param_value_pair" If the current param value pair starts with uid=, then prepend it to the list of query string parameters if {$param_value_pair starts_with "uid="}{ set new_query_string ${param_value_pair}${new_query_string} } else { set new_query_string ${new_query_string}&${param_value_pair} } log local0. "\$new_query_string: $new_query_string" } set new_query_string hxs=1&${new_query_string} log local0. "\$new_query_string: $new_query_string" }
- Gaelle_31283
Nimbostratus
Thanks a lot
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