Forum Discussion

SanjayP's avatar
SanjayP
Icon for Nacreous rankNacreous
Jun 07, 2019

Rewrite first uri string

Requirement is to rewrite only first uri string.

 

Eg. https://www.company.com/test/example/test/index.htm to https://www.company.com/testUI/example/test/index.htm

 

With string map syntax, all "test" in URI part are getting rewrite. also tried split uri to get the first string, set variable and then use string map, but no luck. Can someone please help with any pointer?

 

Thanks

4 Replies

  • try this

    when HTTP_REQUEST {
        HTTP::uri /[join [lreplace [split [string trimleft [HTTP::uri] /] /] 0 0 "testUI"] /]
    }
  • you can also try this:

    when HTTP_REQUEST {
    	if {[scan [HTTP::path] "/test/%s" var]} {
    		HTTP::path /testUI/$var
    	}
    }