Forum Discussion

rajesh1's avatar
rajesh1
Icon for Nimbostratus rankNimbostratus
Apr 28, 2010

IRULE - HTTP REDIRECT

Hi,

 

 

I am new to Irules and i want someone to validate the my irule based on the following requirement.

 

 

we are having a website - www.example.com.au and www.example.co.nz sharing the same virtual ip address and the requirement is to redirect the HTTP request to the remote site if there are no active members in the local pool

 

 

www.example.com.au will be redirected to www2.example.co.au - if no active pool members

 

www.example.co.nz will be redirected to www2.example.co.nz - if no active pool members

 

 

Please check the syntax and logic and correct me if i am missing anything

 

 

when HTTP_REQUEST {

 

if { [active_members POOL-WEB] == 0 } {

 

if { [HTTP::host] contains "example.com.au" } {

 

HTTP::redirect https://www2.example.com.au[HTTP::uri] }

 

elseif { [HTTP::host] contains "example.co.nz" } {

 

HTTP::redirect https://www2.example.co.nz[HTTP::uri] }

 

}

 

else { pool POOL-WEB

 

}

 

}

 

 

Thanks

 

Raj

1 Reply

  • Hello Raj,

     

     

    this iRule is valid in terms of syntax. Have you been able to test it yet? If it doesn't appear to be working check the ltm logs for any errors.

     

     

    I'd definately recommend downloading the iRule Editor, it makes writing and checking iRules alot easier.

     

     

    Thanks.