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

Diamonddust_248's avatar
Diamonddust_248
Icon for Nimbostratus rankNimbostratus
Feb 09, 2016

iRule question

I have a question. I made this iRule with the help of another topic but I wanted to expand on it but not sure what to do about that.

The current iRule makes it so the first batch of websites doesn't redirect to https but i also want it to make everything that starts_with URI to not be included into the redirect either is this possible?

    when HTTP_REQUEST {
  switch -glob [string tolower [HTTP::host][HTTP::uri]] {
     "www.abc.com/xyz/def"
   - "www.abc.com/xyz"
   - "www.abc1.com/xyz/def"
   - "www.abc2.com/xyz/def" 
   - "www.abc3.com/xyz/def" 
   - "www.abc4.com/xyz/def" 
   - "www.abc5.com/xyz/def" 
   - "www.abc6.com/xyz/def"
   - "www.abc7.com/xyz/def"
   - "www.abc8.com/xyz/def"

    {
      return
    } 
    default {
      HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]"
     }
  }
}

1 Reply

  • A few things:

    1. The switch inclusion (-) operator should be at the end of the case, not the beginning.

    2. The -glob operator is effectively a wildcard match that could emulate a starts_with condition using an appropriately placed "*".

    Example:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::host][HTTP::uri]] {
            "www.abc.com/xyz/def*" -
            "www.abc.com/xyz*" -
            "www.abc1.com/xyz/def*" -
            "www.abc2.com/xyz/def*" - 
            "www.abc3.com/xyz/def*" -
            "www.abc4.com/xyz/def*" - 
            "www.abc5.com/xyz/def*" - 
            "www.abc6.com/xyz/def*" -
            "www.abc7.com/xyz/def*" -
            "www.abc8.com/xyz/def*" {
                return
            } 
            default {
                HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]"
            }
        }
    }