For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

SSHSSH_97332's avatar
SSHSSH_97332
Icon for Nimbostratus rankNimbostratus
Aug 08, 2014

HTTP URI Parts

http://www.example.com:8080/main/abc/index.jsp?user=test&login=check

 

In the above , if i want to print second part of URI , which is here "abc" , is this [ [HTTP::uri] 2] or What ?

 

4 Replies

  • Hello,

    You can use this line of codes within irule :

    set uri [HTTP::uri]
    set stripped_uri [getfield $uri "/" 3]
    

    BR

    Yann

  • Thx Why we used "3" i wa sexpecting "2" , as first part of uri is "/main" , so second part is "/abc"

     

  • As far as I remember, when using getfield with "/" delimiter, your url is cut as follow : /main/abc/index.jsp?user=test&login=check

    1 "" <- this is a null string value before the first "/"
    2 main
    3 abc
    4 index.jsp?user=test&login=check
    
  • Yann is absolutely right.

     config
    
    [root@B6900-R69-S40:Active:Standalone] config  tmsh list ltm rule qux
    ltm rule qux {
        when RULE_INIT {
      for { set i 1 } { $i < 10 } { incr i } {
        log local0. "\[getfield /main/abc/index.jsp?user=test&login=check / $i\] = [getfield /main/abc/index.jsp?user=test&login=check / $i]"
      }
    }
    }
    
     /var/log/ltm
    
    [root@B6900-R69-S40:Active:Standalone] config  tail -f /var/log/ltm
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 1] =
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 2] = main
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 3] = abc
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 4] = index.jsp?user=test&login=check
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 5] =
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 6] =
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 7] =
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 8] =
    Aug 10 06:47:01 B6900-R69-S40 info tmm[15765]: Rule /Common/qux : [getfield /main/abc/index.jsp?user=test&login=check / 9] =