Forum Discussion

Rajesh_A_142089's avatar
Rajesh_A_142089
Icon for Nimbostratus rankNimbostratus
Apr 08, 2014

Remove part of querystring

I want to remove specific key=value pair from the querystring if present   -If my uri is /myuri?mykey=myvalue or /myuri?otherkey=othervalue&mykey=myvalue -I want to rewrite the uri such that I rem...
  • IheartF5_45022's avatar
    Apr 09, 2014

    Just one approach;-

    when HTTP_REQUEST {
        if {[URI::query [HTTP::uri]] contains "mykey="} {
            set newq ""
            foreach param [split [URI::query [HTTP::uri]] "&"] {
                if {!($param starts_with "mykey=")} {
                         Build up new query parameter string
                    append newq $param
                }
                 Add new query portion to path
                HTTP::uri "[HTTP::path]$newq"
            }
        }