F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

Lemrock_54160's avatar
Lemrock_54160
Icon for Nimbostratus rankNimbostratus
Jan 31, 2014

Redirect URI to different URL and only keep query strings

Trying to configure an irule to redirect from one server/uri to a different server and only keep the query after the uri

 

For example -

 

http://www.host.com/hello/thisisatest (or anything else after the /hello) redirects to http://newhost.com/thisisatest (or anything else after the /hello above)

 

1 Reply

  • Is the first part of the URI static, or do you need to remove the first part of the URI no matter what it is? If the former, a simple string map should cover it:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/hello" } {
            set newuri [string map {"/hello" ""} [HTTP::uri]]
            if { $newuri eq "" } { set newuri "/" }
            HTTP::redirect "http://[HTTP::host]$newuri"
        }
    }