You can use the "string map" command to do a search and replace quite easily. The following iRule will check to make sure the URI doesn't have the "safe=active" parameter. If it is not present in the URI, then it will replace all occurances of "hl=en" with "hl=en&safe=active". So, if you have more than one "hl=en" in the URI, it will replace both of them. If that's the case, you might want to look for a more unique term.
when HTTP_REQUEST {
if { ! [HTTP::uri] contains "safe=active" } {
HTTP::uri [string map {"hl=en" "hl=en&safe=active"} [HTTP::uri]]
}
}
If you just want to append it to the URI, then you can do so like this:
when HTTP_REQUEST {
if { ! [HTTP::uri] contains "safe=active" } {
HTTP::uri "[HTTP::uri]&safe=active"
}
}
Keep in mind that this may not work if you don't have any querystring arguments in the URI to begin with. The first querystring argument needs to start with a question mark and if you don't have any, this iRule will prefix the only querystring argument with a ampersand.
Hope this is enough to get you started.
-Joe