Forum Discussion

John_Nootens_45's avatar
John_Nootens_45
Icon for Nimbostratus rankNimbostratus
Mar 08, 2005

Help me convert 4.x Rule to 9.x iRule

I built a rule based on everything I could find for examples and documentation in the LTM configuration guide and on devcentral, but I'm not able to get around syntax errors. I'll greatly appreciate any help in converting the 4.5.9 Rule below to a 9.0.4 iRule as I've tried here:

 

 

THIS IRULE:

 

 

iRule PSFT_Rule

 

when CLIENT_ACCEPTED{

 

if { [HTTP::uri] matches_regex "/psreports"} {

 

pool PSFT_Reports

 

} else {

 

pool people_soft

 

}

 

}

 

 

GAVE THESE ERROR MESSAGES:

 

 

01070151:3: Rule [PSFT_Rule] error:

 

line 1: [wrong args] [when CLIENT_ACCEPTED{]

 

line 2: [command is not valid in the current scope] [if { [HTTP::uri] matches_regex "/psreports"} {

 

pool PSFT_Reports

 

} else {

 

pool people_soft

 

}]

 

line 7: [command is not valid in the current scope] [}]

 

 

HERE WAS THE ORIGINAL 4.5.9 Rule:

 

 

rule PSFT_Rule {

 

if (http_uri matches_regex "/psreports") {

 

use pool PSFT_Reports

 

}

 

else {

 

use pool people_soft

 

}

 

}

 

2 Replies

  • First of all, you don't specify the rule name in the rule itself in the GUI. Second, it looks like there must be a space between the event name and a curly brace. Another thing is that you might want to use the "starts_with" or "contains" operators so you don't incur the overhead of a regular expression search.

    Give this a try, it should do the trick...

     when CLIENT_ACCEPTED { 
         if { [HTTP::uri] contains "/psreports"} { 
           pool PSFT_Reports 
         } else { 
           pool people_soft 
         } 
      }

    -Joe