For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

T5C's avatar
T5C
Icon for Altocumulus rankAltocumulus
Mar 01, 2022

irule - check query parameter

Hi

I would like to check if specific query parameter (ids) in url is above some numeric value (300), if yes then redirect to specific page.

Sample https request: https://xyz.ab/some/path/additition?lang=en&ids=300

How to check if this parameter is only number and not string  ?

Sample irule

WHEN HTTP_REQUEST {

if {[HTTP::uri] starts with "/some/path" and [URI::query [HTTP::uri] ids ] > 300 }

{ HTTP::redirect "https://xyz.ab/404.html" }

}

When i add some string to ids for example ids=300ab above irule also redirects so  how to validate this query parameter so that if and only if it is a number and is above 300 it will redirect to specific page ?

1 Reply

  • xuwen's avatar
    xuwen
    Icon for Cumulonimbus rankCumulonimbus
    when HTTP_REQUEST priority 500 {
        set ids [URI::query [HTTP::uri] ids]
        if { [HTTP::uri] starts_with "/some/path" && [catch { expr { int($ids) > 300 } } res] == 0 && $res == 1 } {
            HTTP::redirect "https://xyz.ab/404.html"
        }
    }