Forum Discussion

Murugs_322349's avatar
Murugs_322349
Icon for Nimbostratus rankNimbostratus
Jun 02, 2017

irule scan help in 12.x

I have a requirement to split the uri into two variables. First part of uri should be in one variable and all remaining uri should be in second variable.

 

If the uri is https://abc.com/abc/def/ghi?123 then

 

var1 should be abc var2 should be /def/ghi?123

 

I tried the below scan command but getting error

 

when HTTP_REQUEST { set reqPath [HTTP::uri] scan $reqPath {/%[^/]%s} service url HTTP::uri "$url" }

 

TCL error: dev1-rule - can't read "url": no such variable while executing "HTTP::uri "$url""

 

 

F5 Version : BIG-IP 12.1.2 Build 0.0.249 Final

 

1 Reply

  • Hi

    You must evaluate if the scan command matches the whole filter.

    when HTTP_REQUEST { 
        set reqPath [HTTP::uri]        
        if { [scan $reqPath {/%[^/]%s} service url] == 2} {      
            HTTP::uri "$url"             
        } {         
             something wrong in URL. No second slash discovered            
            HTTP::uri "/"   
        }      
    }