Help with a redirect with a uri modification.

I am having an issue where I need to redirect a particular site on SharePoint to a different server farm.

I would like to see and anything that comes after the apr redirected to and include the anything after the apr from above

so if I go to he would get redirected to

but if sally came along and went to she would get redirected to

I have this already and it kinda works

when HTTP_REQUEST {
    if { [HTTP::uri] contains "/apr" } {    
        HTTP::redirect "https://sharepoint2/sites/apr"
    }
}

The problem is everything gets redirected to /sites/apr and doesn’t include /chris or /sally. I know that is what my irule says to do but how would I include whatever is in the rest of the string after /apr and change the /techservices/govern to sites?

Thanks in advance for any help.

Hi Chris,

you may try the snippet below. It uses the

[string range]

syntax, to cut the first 20 characters from the requested

[HTTP::uri]

to build the redirect location…

when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] starts_with "/techservices/govern/apr" } then {
        HTTP::redirect "https://sharepoint2/sites[string range [HTTP::uri] 20 end]"
    }
}

Cheers, Kai