Forum Discussion

Fready_Ball's avatar
Fready_Ball
Icon for Nimbostratus rankNimbostratus
Oct 14, 2020

Modify blank URI

I am using this to modify get request in F5 to real server.

if { [HTTP::uri] starts_with "/supervisor" } {

HTTP::uri [string map {"/supervisor" "/admin"} [HTTP::uri]]

}

 

and it works OK.

 

but i need to change the get request to /user but only if URI is blank.

 

so abc.com/ will send get abc.com/user

 

 

I have tried this...

 

if { [HTTP::uri] starts_with "/" } {

HTTP::uri [string map {"/" "/user"} [HTTP::uri]]

}

 

this kind of works as i see get abc.com/user but it then adds /user to all URI's, so abc.com/admin becomes abc.com/useradmin

 

so i only need to add /user if the URI is blank,

 

any help appreciated as going bonkers...

 

  • Hi Fready Ball,

    You must use equals instead of starts_with.

    if { [HTTP::uri] equals "/" } {
    	HTTP::uri [string map {"/" "/user"} [HTTP::uri]]
    }
  • Hi Fready Ball,

    You must use equals instead of starts_with.

    if { [HTTP::uri] equals "/" } {
    	HTTP::uri [string map {"/" "/user"} [HTTP::uri]]
    }
    • Fready_Ball's avatar
      Fready_Ball
      Icon for Nimbostratus rankNimbostratus

      Hi eaa, many thanks for your quick response. I will be testing this morning.

    • Fready_Ball's avatar
      Fready_Ball
      Icon for Nimbostratus rankNimbostratus

      added with elseif and works a treat... thanks again eaa.