For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Alexander_Slink's avatar
Alexander_Slink
Icon for Altostratus rankAltostratus
Aug 01, 2016

Change only first slash in URI.

Hello everyone!
I want change only first slash in uri on a some word.
i.e.: http://example.com/test/picture.jpg

And after change URI must be http://example.com/after_change/test/picture.jpg

I've tried to do with iRule:

when HTTP_REQUEST {
      log local0. "Incoming URI = [HTTP::uri]"
      if { [string tolower [HTTP::uri]] starts_with "/" } {
      set uri [string map -nocase {"/" "/after_change/"} [HTTP::uri]]
      log local0. "New URI = $uri"
      HTTP::uri $uri
      }
                        }

But this iRule change all slashes in URI:
http://example.com/after_change/test/after_change/picture.jpg


Help needed!                                                                                                                                                                                                                                                              

1 Reply

  • Hi Alexander,

    to add a fixed subfolder to every URI, you may want to try the syntax below...

    when HTTP_REQUEST {
          log local0. "Incoming URI = [HTTP::uri]"
          HTTP::uri "/after_change$uri"
          log local0. "Outgoing URI = [HTTP::uri]"
    }
    

    Cheers, Kai