I think there are a number of things that can be improved in your example. But, let's not start there yet.
First, let's gather more information about what you're trying to do.
It sounds like you want to insert some path data before certain uris.
So, the first question that comes to mind is whether the inserted rewrite text is different depending on the original uri?
Second, I'm not quite sure how/why you are relating the two datagroups with each other. Perhaps you really just want one datagroup with two fields.
For example, I might have a datagroup that looks like this:
class my_uri_mappings {
"/index.html /some/place/for/html"
"/pretty.gif /some/place/for/images"
"/unknown.html /some/place/for/hackers"
}
I might then have a rule that looks of the uri in the datagroup and inserts the second portion of it. This example relies on the fact that when the findclass command is supplied with a separator (the 3rd argument) it will return the latter portion of the entry that matches the beginning portion:
when HTTP_REQUEST {
set rewrite [findclass [HTTP::uri] $::my_uri_mappings " "]
if { $rewrite ne "" } {
HTTP::uri [concat $rewrite [HTTP::uri]]
}
}
The next example relies on the fact that the matchclass command returns the list index + 1 of a matching entry. Since it doesn't appear that you are actually rewriting the original portion of the uri, but only inserting a leading string, this approach could also be used:
class my_uri_mappings {
"/some/place/for/html/index.html"
"/some/place/for/images/pretty.gif"
"/some/place/for/hackers/unknown.html"
}
when HTTP_REQUEST {
set rewrite [matchclass $::my_uri_mappings ends_with [HTTP::uri]]
if { $rewrite } {
HTTP::uri [lindex $::my_uri_mappings [expr $rewrite - 1]]
}
}