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

cquick11_115408's avatar
cquick11_115408
Icon for Nimbostratus rankNimbostratus
Mar 27, 2014

A "catch all rule" for redirects

We were trying to create a rule with specific redirects, but instead of creating a rule for every domain, we would like to use a default catch. So far we have this, we had the event disable and disable all, but that didn't work correctly. I added return instead, and that is looking ok so far. I am concerned about the resource hit as everything for joe.com will hit the first rule. Is there a better way to do this?

when HTTP_REQUEST {
    if {([string tolower [HTTP::host]] ends_with "joe.com")} {
        log local0. "[IP::client_addr] [HTTP::host][HTTP::uri] Disable Irule" 
        return
        }
        switch -glob [string tolower [HTTP::host]] {
        "*sue.com" {
       HTTP::respond 301 Location "http://www.joe.com/sue/Default.aspx"
        }
        default {HTTP::respond 301 Location "http://www.joe.com/joe/default.aspx"}
    }
}

2 Replies

  • Try this:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::host]] {
            "*.joe.com" { return }
            "*.sue.com" { HTTP::redirect "http://www.joe.com/sue/Default.aspx" }
            default { HTTP::redirect "http://www.joe.com/joe/Default.aspx" }
        }
    }