Parse URI to remove specified value if present, then return the rest

Hello, I’m working with a customer who would like an iRule that would remove “?asm=true” from the uri if it is present. At that point, it would just pass along the rest of the request without the “?asm=true” part. Any ideas on how to do that?

Thanks!

Hi Jayrod,

If the

asm=true

query is already send by the user, then try this snippet…

when HTTP_REQUEST {
    if { [HTTP::query] contains "asm=true" } then {
        if { [HTTP::query] equals "asm=true" } then {
            HTTP::uri [HTTP::path]
        } elseif { [HTTP::query] starts_with "asm=true&" } then {
            HTTP::uri [string map [list "asm=true&" ""] [HTTP::uri]]
        } else {
            HTTP::uri [string map [list "&asm=true" ""] [HTTP::uri]]          
        }          
    }
}

If the

asm=true

query is injected by ASM (I duno if ASM add this param?), then you may try this snippet…

when HTTP_REQUEST_SEND {
    clientside {
        if { [HTTP::query] contains "asm=true" } then {
            if { [HTTP::query] equals "asm=true" } then {
                HTTP::uri [HTTP::path]
            } elseif { [HTTP::query] starts_with "asm=true&" } then {
                HTTP::uri [string map [list "asm=true&" ""] [HTTP::uri]]
            } else {
                HTTP::uri [string map [list "&asm=true" ""] [HTTP::uri]]          
            }          
        }
    }
}

Cheers, Kai