Forum Discussion

JayrodEF_161281's avatar
JayrodEF_161281
Icon for Nimbostratus rankNimbostratus
Feb 08, 2016

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!

 

1 Reply

  • 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