Using Conditional Rules
A conditional rule basically consists of a special function type of PageBlaster token syntax that allows an IF condition to be evaluated before executing the rules that it contains. The syntax of an IF function is as follows:
[PB: IF(expression1 evaloperator expression2 ) {true condition }else{false condition} ]
Where:
expression1: can be a literal term or the result of an inner function
Inner functions are:
Match ( expression1, expresion2 ) where expression2 can use regular expressions
Len (expresion1)
Left (expresion1,length)
Right (expresion1,length)
Substring(expresion1, start, length)
evaloperator: can be any of the following operators: =, == , != , <> , >=, <=, <, >
equals, not equals, greater than or equal to, less than or equal to, less than, greater than
expression2: same as expression 1
Expressions can be literal or you can use PB: tokens
The condition statements are enclosed in curly braces
The eval operator and expression are optional if you are using an inner function that evaluates to true or false.
The else part with the false condition is optional
So an example conditional statement that could be used to match on a Url and do a 301 redirect would look like this:
[PB: IF( Match("[PB:Request.Url]","http://snapsis.com") ) {
[PB: Response.Status("301 Moved Permanently") ]
[PB: Response.AddHeader("Location","http://www.snapsis.com") ]
[PB: Response.End() ]
} ]