Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

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!

0
Rate this Question
Comments on this Question
Comment made 3 months ago by Rabbit23 462

this wont work because DGLIST is in CAPS and you are calling the tolower method

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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 }
}
0
Comments on this Answer
Comment made 19-Feb-2018 by maayan yosef 2

Thanks Stanislas for your knowledge sharing !

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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 
    }
}
0
Comments on this Answer
Comment made 19-Feb-2018 by maayan yosef 2

Thanks MrPlastoc for your knowledge sharing !

0