Forum Discussion

Sheetal_43349's avatar
Sheetal_43349
Icon for Nimbostratus rankNimbostratus
Jul 02, 2018

URI Trimming

Hello,

I am making an irule where if the irule contains certain character in this case lets say AA, it should remove AA and modify the uri as it is .so, lets say if the url is https://abc.com/AA/xyz, then it should modify it to https://abc.com/xyz and then take it to pool_AA.

I have made this irule but it doesnt seem to be working:

Please advise:

when HTTP_REQUEST { if { [[HTTP::uri]] starts_with "/AA/"} { HTTP::uri [string trimleft [HTTP::uri] /AA]

   pool pool_AA
}
if { [[HTTP::uri]] starts_with "/BB/"}
{
    HTTP::uri [string trimleft [HTTP::uri] /BB]

    pool pool_BB
}
}
  • According to this page, the string "/AA" means it remove every characters until the character is not / or A or A

     

    so the URI /AA/xyz will become xyz (without the first /)

     

  • Hi,

    you can use string range:

    when HTTP_REQUEST {
       set uri [HTTP::uri]
       if { $uri starts_with "/BB" } {
         set uri [HTTP::uri]
         HTTP::uri [string range $uri 3 end]
       }
    }