Forum Discussion

Murali_Thutera_'s avatar
Murali_Thutera_
Icon for Nimbostratus rankNimbostratus
Jan 21, 2011

iRule for conditional page redirection

Hi Guys,

 

 

I am new to iRule and i need help in writing the iRule for pagre redirection with condition.

 

 

Scenario

 

1.When user hits the big-ip first it should check the source IP and based on that it should redirect it to different url.

 

 

2. After checking the IP it should read the external which will be placed in big-ip unit itself I have the captured the user names.If user name is not there in the file then it shpould redirect. If the user name is not present it should not redirect.

 

 

Need the iRule where it will read the source ip first then read the external file. If source IP is matching and user name is not present in the external file then redirect else dont redirect.

 

 

F5 OS is BIG-IP 9.6.1

 

 

Any help will be appreciated.

 

2 Replies

  • Did you want to define the IPs getting redirected inside a data group/class or is it simply a network you'd like to reference from the iRule? Also, if the username doesn't exist in the external class, do redirect or don't?

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    This is definitely doable, assuming the username you're talking about using to base your redirects on is readable in the request. All you'd need to do, as Chris alluded to, would be to create a data group for the IPs that you want to redirect. The key would be the IP you want to redirect, the value of each entry would be what host/IP you want them redirected to. You'd then need to create another data group with user names in it. All you'd need then is to create an iRule that does a findclass on the first datagroup to see if the IP is matched and grab the associated value (the new IP/host to redirect the user to), then perform a matchclass on the data group containing usernames. If the user isn't present, redirect to the newly queried host/IP and you should be set.

     

     

    Let us know if you need help with any of the specific steps in the code.