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

Qamar_Zia_13515's avatar
Qamar_Zia_13515
Icon for Nimbostratus rankNimbostratus
Jun 01, 2014

IRULE Help

Hi,

 

I need IRULE help to acheive the below requirement:

 

Request for (abc.gov.us) Redirect to (abc.us)

 

Request for ecouncil.us (abc.encouncil.us)

 

Appreciate if some one help me out at the earliest, need to acheive both redirections in the same IRULE.

 

Regards,

 

3 Replies

  • Hi Qamar,

    I think you are looking for something like the following:

    when HTTP_REQUEST {
        if {[HTTP::uri] eq "/" } {
                switch -glob [string tolower [HTTP::host]] {
                     "abc.gov.us" { HTTP::redirect "http://abc.us[HTTP::uri]" }
                     "ecouncil.us" { HTTP::redirect "http://abc.encouncil.us[HTTP::uri]" }    
                }
               }
            }
    

    I hope this helps,

    -=Bhattman=-

  • Try this one:

    when HTTP_REQUEST {
    
        set host [string tolower [HTTP::host]]
    
        switch $host {
            "abc.gov.us" { HTTP::respond 301 Location "http://abc.us" }
            "ecouncil.us" { HTTP::respond 301 Location "http://abc.ecouncil.us" }
        }
    
    }
    

    /Patrik

  • e.g.

    [root@ve11a:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      if { [HTTP::uri] eq "/" } {
        switch [HTTP::host] {
          "abc.gov.us" {
            HTTP::redirect "http://abc.us/"
          }
          "abc.encouncil.us" {
             do something"
          }
          default {
             do somethingelse
          }
        }
      }
    }
    }
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10 -H "Host: abc.gov.us"
    HTTP/1.0 302 Found
    Location: http://abc.us/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0