Forum Discussion
Mike_Pimlott_61
Nimbostratus
Jun 24, 2008safesearch - google et al
apologies if this sits somewhere else in the forums. a search didn't turn anything up.
I have a requirement to implement safesearch through the LTM, without forcing traffic through a p...
Jun 24, 2008
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
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
