Forum Discussion

Domai_23823's avatar
Domai_23823
Icon for Nimbostratus rankNimbostratus
Sep 13, 2018

error: [undefined procedure: default][default { discard }]

Hello Guys, I have the below iRule and when I try to apply it I get the error - "error: [undefined procedure: default][default { discard }]"

When the users type in "https://topgear.com/current/cars/models" I want the traffic to hit the toyota_pool but if the users don't type anything in the uri and type "https://topgear.com" I just am looking to redirect it to "https://cars.com"

What am I missing here? - Thank you

 when HTTP_REQUEST
{
    set host [HTTP::host]
    set hostLowered [string tolower $host]
    set uri [HTTP::uri]
    set uriLowered [string tolower $uri]

    switch -glob $hostLowered
    {
        "topgear.*" {       
          if { $uriLowered contains "car"  } then {
            SSL::disable serverside
            pool toyota_pool
          } else {
          if { $uriLowered equals "/"  }
            { HTTP::respond 301 Location "https://cars.com" }
        }
        default { discard }
   }
}
}           
  • The closing curly bracket before default close the else statement... you have to add one more to close the switch top gear item!

     

  • Try this indentation and with just two variables (performance +up):

    when HTTP_REQUEST {
    
        set host [string tolower [HTTP::host]]
        set uri [string tolower [HTTP::uri]]
    
        switch -glob $host {
            "topgear" {       
                if { $uri contains "car"  } {
                    SSL::disable serverside
                    pool toyota_pool
                }
                else {
                    if { $uri equals "/"  } {
                        HTTP::respond 301 Location "https://cars.com"
                    }
                }
            }
            default {
                discard
            }
        }
    }
    
    • Domai's avatar
      Domai
      Icon for Altostratus rankAltostratus

      Dammm thanks...I don't know how I missed that.