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

DM_5174's avatar
DM_5174
Icon for Nimbostratus rankNimbostratus
Jun 09, 2008

Formatting irule from 4.x to 9.x question

Hi All,

What I have below is an i-rule i created for the bigip version 4.x, however when I tried to format this to work on

the 9.x platform I'm having issues with the regular expression converstion and don't know what the syntax for 9.x is.

If anyone can provide any guidance and feedback, this would be greatly appreciated.



if (http_host == "www.abc.com" and http_uri matches_regex "/[pP][oO][rR][tT][aA][lL]") {
   redirect to "www.new-redirect.com/portal/index.html"
}
else {
   use pool WEBSERVER_POOL
}

Thanks!

4 Replies

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Here is a 9.x equivalent:

     
     when HTTP_REQUEST { 
        if {[string tolower [HTTP::host]] eq "www.abc.com" and [string tolower [HTTP::uri]] eq "/portal") { 
           HTTP::redirect "www.new-redirect.com/portal/index.html" 
        } else { 
           pool WEBSERVER_POOL 
        } 
     } 
     

    Aaron
  • Well, I'm guessing the rule as you defined it there is going to error out. You're using parens () instead of curly braces {} around the if clause.

     

     

    Does that help at all?
  • Hi Aaron,

     

     

    The "portal" should not be case-sensitive, i.e. so if a user connects with http://www.abc.com/PoRtAl using mix case letters (capital and lowercase) they should get redirected to the new url. Will this work? or do i need to use the following code below?

     

     

    if { [regexp -nocase {^/portal} [HTTP::uri]] } {

     

     

     

    Thanks!
  • The string tolower will strip case so the regex is unnecessary.