Forum Discussion

Tadeo_Picazo_37's avatar
Tadeo_Picazo_37
Icon for Nimbostratus rankNimbostratus
Oct 12, 2018

Modify uri request

Hi i am new on the F5, Do you know if there is a way to modify the uri and redirect to a new path, basically we would like to check if the URI does not contain like /test1/../ or /Test2/../ then add /newpage/Test1/../

we have been doing something like this

when HTTP_REQUEST { log local0. "incoming URI: [HTTP::uri]"

 if { [HTTP::host] contains "VIP" } {

      if { (!([string tolower [HTTP::uri]] contains "/test1/")) || (!([string tolower [HTTP::uri]] contains "/test2/")) } {

          set newpath [HTTP::host]"/newpage/test1[HTTP::uri]"
          log local0. "redirecting to https://$newpath"
          HTTP::redirect "https://$newpath"

           }
    }
}
  • It looks pretty close.

    if { [HTTP::host] contains "VIP" } {
        if { (!([string tolower [HTTP::uri]] contains "/test1/") && !([string tolower [HTTP::uri]] contains "/test2/")) } {
           HTTP::redirect "https://[HTTP::host]"/newpage/test1[HTTP::uri]"
        }
    }