Combine two iRules

Hi - I am trying to combine two iRules on 9.x.

I believe a switch -glob statement would be appropriate, but not sure how do it with two different HTTP::‘operators.’

when HTTP_REQUEST {

if { !([HTTP::path] equals “http://test/niku/app”) } {

HTTP::redirect “https://test.testmarketing.com[HTTP::uri]”

}

}

when HTTP_REQUEST {

if { [HTTP::host] equals “test” } {

HTTP::redirect “https://test.testmarketing.com[HTTP::uri]”

}

}

Suggestions?

Thanks!

-TJ

I am not sure I follow completely, but it seems to me that this would do the trick:

when HTTP_REQUEST {
    if { ([HTTP::host] equals "test") & (!([HTTP::uri] equals "/niku/app")) } {
        HTTP::redirect "https://test.testmarketing.com[HTTP::uri]"
    }
}

Replace & with && or and

i think the 2nd HTTP_REQUEST is superset of the 1st one.

I read the request as “I want to redirect all traffic to this host, except for this one path”

I read the request as “I want to redirect all traffic to this host, except for this one path”

thanks. i overlooked not (!) in the question.

Sorry for the confusion guys. Let me update some words so that it doesn’t supersede itself.

Brain - I have always wanted some explanation to ‘&&’. This is an ‘or’ statement correct, not an ‘and’ statement, correct?

I’m looking for an ‘OR’

when HTTP_REQUEST {

if { ([HTTP::host] equals “nice”) && (!([HTTP::uri] equals “/niku/app”)) } {

HTTP::redirect “https://nice.testmarketing.com[HTTP::uri]”

}

}

Thanks!

-TJ

pls feel free to revise.

[root@orchid:Active] config  b virtual bar80 list
virtual bar80 {
   snat automap
   pool foo80
   destination 172.28.17.88:http
   ip protocol tcp
   rules myrule
   profiles
      http
      tcp
}
[root@orchid:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
   if {[string tolower [HTTP::host]] equals "nice" and [string tolower [HTTP::uri]] ne "/niku/app"} {
      HTTP::redirect "https://nice.testmarketing.com[HTTP::uri]"
   }
}
}

[root@orchid:Active] config  curl -I http://nice/niku/app
HTTP/1.1 404 Not Found
Date: Thu, 15 Sep 2011 17:12:10 GMT
Server: Apache/2.0.59 (rPath)
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

[root@orchid:Active] config  curl -I http://nice/abc
HTTP/1.0 302 Found
Location: https://nice.testmarketing.com/abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

Brian - I have always wanted some explanation to ‘&&’. This is an ‘or’ statement correct, not an ‘and’ statement, correct?

The && is an AND statement and || is an OR statement. If you use an OR the above example, a person going to nice/niku/app will get redirected since it evaluated the left side first.

Thanks for your help guys. Much appreciated!

-TJ