Forum Discussion

Mike_Wethington's avatar
Icon for Nimbostratus rankNimbostratus
Oct 18, 2010

Redirect to new uri with part of original uri

I am trying to redirect a url by using a portion of old a new.




original request



redirected to



i need to look for the /update/ (from the original request) and take everything after the update/blahblah (so the blahblah) and tack it on to the end of



I am struggling to get this done. Any help would be appreciated.


3 Replies

  • Hii Mike,

    You can use 'string range' to parse the original URI. I've added URI encoding of the URI to ensure there aren't any encoding errors in the redirect. If that's not what you want, you can remove that portion.

    TCL string range man page

    when HTTP_REQUEST {
        Check if URI starts with /update
       if {[string tolower [HTTP::uri]] starts_with "/update"}{
           Redirect the request
          HTTP::redirect "[URI::encode [string range [HTTP::uri] 7 end]]"
          log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting [HTTP::uri]\
             to[URI::encode [string range [HTTP::uri] 7 end]]"

  • Thank you for the respone. So if i understand correctly the statement [HTTP::uri] 7 end]] will only take what appears after the /update/ correct?
  • Exactly:



    % string range "/update/1234" 7 end