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

jburford2's avatar
jburford2
Icon for Nimbostratus rankNimbostratus
Mar 30, 2022

URL and URI redirect

My F5 has one virtual server for all URL's. I need to set a pool based on one of two matching URL's and a matching URI. the code below is what I am trying, the F5 gives me error everytime I try to update the irule.. it doen not like "else or Elseif"

 

 

when HTTP_REQUEST {
    set host [string tolower [HTTP::host]]
    set uri [string tolower [HTTP::uri]]
    if { $host contains ".x." } {
        if { $uri starts_with "/new" } 
            {pool "X_NEW"}
        }		
    Else
    if { $host contains ".y." } {
		if { $uri starts_with "/new" } 
           { pool "Y_NEW"}
        }
}

 

 

 

3 Replies

  • 01070151:3: Rule [/Common/KTN_ROUTER] error: /Common/KTN_ROUTER:30: error: [missing a script after "if"][ ]
    /Common/KTN_ROUTER:32: error: [undefined procedure: pool "X_NEW"][{pool "X_NEW"}]
    /Common/KTN_ROUTER:34: error: [undefined procedure: Else][Else]
    /Common/KTN_ROUTER:38: error: [missing a script after "if"][ ]
    /Common/KTN_ROUTER:40: error: [undefined procedure: pool "Y_NEW"][{ pool "Y_NEW"}]
    
    when HTTP_REQUEST {
        set host [string tolower [HTTP::host]]
        set uri [string tolower [HTTP::uri]]
        if { $host contains ".x." } {
            if { $uri starts_with "/new" } 
                {pool "X_NEW"}
            }		
        Else
        if { $host contains ".y." } {
    		if { $uri starts_with "/new" } 
               { pool "Y_NEW"}
            }
    }
  • Hi I would like to sent solution that relate about your requirement, Please find the irules below,

    when HTTP_REQUEST {
    set httphost [string tolower [HTTP::host]]
    set httpuri [string tolower [HTTP::uri]]

    if { ($httphost contains "x1") && ($httpuri starts_with "/y1") } {
    pool pool1
    } elseif { ($httphost contains "x2") && ($httpuri starts_with "/y2") } {
    pool pool2
    } else {
    pool pool3
    }
    }

    Please find detail of irules in link below, 

    https://cloud-ttrust.com/f5-irules-check-http-host-and-uri/