Ahh, you learn something new every day.
You can use store mappings in a datagroup. You can store both strings space delimited in the datagroup and use the findclass method to extract them.
check out the
findclass docs for some examples:
http://devcentral.f5.com/wiki/default.aspx/iRules.findclassClick here
Let's say you have these four mappings defined in a string datagroup (this is the bigip.conf rendering of the data group)
class redirects {
/cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=A http://redirect1.com/path1
/cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=B http://redirect2.com/path2
/cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=C http://redirect3.com/path3
/cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=D http://redirect4.com/path4
}
You could then use the following to lookup the first key and extract the second.
when HTTP_REQUEST {
set my_redirect [findclass [HTTP::uri] $::redirects " "]
if { $my_redirect ne "" } {
HTTP::redirect $my_redirect
}
}
Keep in mind that the findclass command is not case sensitive so if you need to worry about both upper and lower cases in requests, lowercase the strings in the datagroup and use the
string tolower command on the HTTP::uri variable.
-Joe