I have a feeling you were already attempting to handle this within a switch statement, leading me to be believe you want to be able to handle multiple uris....
may I suggest something like the following:
rule replace_uri {
when HTTP_REQUEST {
switch -regexp "[string tolower [HTTP::uri]]" {
"^/compute/v1/" {
set replace_uri [string replace [HTTP::uri] 0 11 "/compute/v2/"]
HTTP::respond 301 Location "http://[HTTP::host]$replace_uri"
}
"^/some/other/uri/you/want/to/replace/" {
set replace_uri [string replace [HTTP::uri] 0 35 "/some/other/target/"]
HTTP::respond 301 Location "http://[HTTP::host]$replace_uri"
}
}
}
}
this "switches" against the uri to look for a "/compute/v1/" at the beginning of the uri. if it finds it, it creates a variable, replace_uri, where it replaces string indices 0 to 11 (that is "/compute/v1/") with "/compute/v2/". It then redirects to http://[HTTP::host]$replace_uri
the second conditional "switch" looks for "/some/other/uri/you/want/to/replace/" at the beginning of the uri. if it finds it, it creates a variable, replace_uri, where it replaces string indices 0 35 (that is "/some/other/uri/you/want/to/replace") with "/some/other/target/". It then redirects to http://[HTTP::host]$replace_uri
if neither conditional is met in the switch statement, then nothing happens