Forum Discussion

joan_luque_1763's avatar
joan_luque_1763
Icon for Nimbostratus rankNimbostratus
Jan 07, 2015

How add URL parameter

Hi guys,

I have to add a parameter at the end of the URI for all the HTTP requests.

My problem is that the request URI could contain some parameter. How I can add a new one whether there is already parameters in the URI?

I wrote the following iRule and it works, but is not so elegant...

when HTTP_REQUEST {  
         if { [HTTP::uri] contains "?" } {
                HTTP::uri [HTTP::uri]&parameter=abc
         } else { 
                HTTP::uri [HTTP::uri]?parameter=abc
         }
}

Any other ideas?

Thanks!

3 Replies

  • I think the way that you have it is probably the easiest (best) way. There have been a couple other questions on this same topic, like this one, and those generally agree with your approach.

     

  • Hi Michael J,

     

    I have looked for a while a best solution but I only found this one. I would like found some kind of macro to just add a new parameter in the URL without a previous check.

     

    Thanks anyway!

     

    • Michael_Jenkins's avatar
      Michael_Jenkins
      Icon for Cirrostratus rankCirrostratus
      Would be nice to have, i agree. There is the possibility of creating a custom procedure that could do this for you (see this article on procs: https://devcentral.f5.com/s/articles/getting-started-with-irules-procedures), but it may not be worth it unless you have a lot of instances like this and want to reduce code.