Forum Discussion

Chris_Grabill_2's avatar
Chris_Grabill_2
Icon for Nimbostratus rankNimbostratus
Feb 01, 2016

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.

1 Reply

  • 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