Forum Discussion

maayan_yosef_20's avatar
maayan_yosef_20
Icon for Nimbostratus rankNimbostratus
Feb 19, 2018

iRule - Redirect by query string from datagroup

Hi Support, I need your help to set iRule that will check string on the query from data group and if he exist we'll redirect to external url if not the traffic will go to internal pool

the request will be app.domain.com/?id=p0000&d=11111

the datadgroup should contain id's (string : p0000 )

Example :

when HTTP_REQUEST {
    if { [string tolower [HTTP::query] ] contains "DGLIST" }
                { HTTP::redirect "http://app.domain.com[HTTP::uri]" }
                else
                { pool app_pool }
}

This is OK ?

Thanks for the help!

3 Replies

  • Hi,

     

    First, Devcentral is not support. We are F5 users sharing our knowledge to other F5 users. I hope you will share your knowledge too.

     

    if you want to filter on query string parameter id, you can use this code:

     

    when HTTP_REQUEST {
        if { [class match [string tolower [URI::query [HTTP::uri]] id ] equals "DGLIST"] }
            { HTTP::redirect "http://app.domain.com[HTTP::uri]" }
        else
            { pool app_pool }
    }
  • Almost, you just need to use

    class match
    to lookup the DG:

    when HTTP_REQUEST {
        if {[class match [string tolower [HTTP::query]] contains "dglist"]} {
            HTTP::redirect "http://app.domain.com[HTTP::uri]" 
        } else { 
            pool app_pool 
        }
    }