Forum Discussion

debo_nair_57395's avatar
Icon for Nimbostratus rankNimbostratus
May 23, 2012

String replace question on [HTTP::path] help !!




sorry if this is too simple of a question to ask but I just started on irules a few months back.




I have [HTTP::path] = /intl/es_US/hotels/hotelsLanding and want to replace the first 11 characters with /es-us/ and append hotels/hotelsLanding to it.




Would the following work ?




"/intl/es_US*" {


set replace_path [string replace [HTTP::path] 0 11 "/es-us/"]








Would the value of ${replace_path} be /es-us/hotels/hotelsLanding ? If not how can I get the right value.






1 Reply

  • Hi debo_nair,

    You didn't specify if you wanted to perform a redirect after you made the modification, if you do then you could do something like this:

    when HTTP_REQUEST {
         if { [string tolower [HTTP::path]] starts_with "/abc" } {
              HTTP::redirect [string map {"abc" "def"} [HTTP::uri]]

    Hope this helps.