Forum Discussion

Ravi_Rajan_7549's avatar
Ravi_Rajan_7549
Icon for Nimbostratus rankNimbostratus
Feb 16, 2007

Redirect Rule with MatchClass

Hi,

 

 

I am new to irules and need some help. I have a current rule like this -

 

 

when HTTP_REQUEST {

 

if { [matchclass [ string tolower [HTTP::uri] ] contains $::xyz]}

 

{HTTP::redirect "http://172.25.10.10/offline/appsoffline.html"}

 

}

 

 

Above will match the incoming uri with the datagroup and will take appropriate action.

 

 

I want the reverse of it, like If the URI matches the datagroup pass the request as it is and if some other URI comes in, then do a http::redirect.

 

 

TIA,

 

 

Ravi

2 Replies

  • You can either use the "!" (not) operator or an else clause.

    when HTTP_REQUEST {
      if { ![matchclass [ string tolower [HTTP::uri] ] contains $::xyz] } {
        HTTP::redirect "http://172.25.10.10/offline/appsoffline.html"
      }
    }

    -or-

    when HTTP_REQUEST {
      if { [matchclass [ string tolower [HTTP::uri] ] contains $::xyz]} {
      } else {
        HTTP::redirect "http://172.25.10.10/offline/appsoffline.html"
      }
    }

    Either should work...

    -Joe