Forum Discussion

Antony2015's avatar
Antony2015
Icon for Altostratus rankAltostratus
May 14, 2015

rewrite iRule

How to write the below iRule if I want to use the two events together ?

event&Condition:

when CLIENT_ACCEPTED {

Client IP:[IP::client_addr] equals 10.0.0.0/8

} when HTTP_REQUEST { if { [string tolower [HTTP::header User-Agent]] contains "/Firefox" or "/Chrome" or "/Opera" or "/safari" }

Action

The action is to rewrite the URI.

-reqUrlFrom "https://www.f5.com/citrix/wwl_prodweb/" -reqUrlInto "https://www.f5.com/citrix/wwl_prodwebExplicit/"

Any help would be highly appreciated !

1 Reply

  • is it something like this?

    when HTTP_REQUEST {
      if { [IP::addr [IP::client_addr] equals 10.0.0.0/8] } {
        if { [HTTP::uri] equals "/citrix/wwl_prodweb/" } {
          switch -glob [HTTP::header "User-Agent"] {
            "*Firefox*" -
            "*Chrome*" -
            "*Opera*" -
            "*safari*" {
              HTTP::redirect "http://[HTTP::host]/citrix/wwl_prodwebExplicit/"
            }
            default {
               User-Agent is not FF, Chrome, Opera, safari
               Do something
            }
          }
        } else {
           URI is not equal to /citrix/wwl_prodweb/
           Do something
        }
      } else {
         IP is not in 10.0.0.0/8 subnet
         Do something
      }
    }