Forum Discussion

funduval's avatar
Icon for Nimbostratus rankNimbostratus
Sep 08, 2022

Simple redirect of host name only, keeping the paths and query params in the redirect the same

Hi I'm kind of surprised I haven't been able to find a simple answer for this.

We need to redirect (also see requirements below):<some_dynamic_value>&client_id=<some_dynamic_value>&scope=<some_dynamic_value>&redirect_uri=<some_dynamic_value>


Requirement #1: we can't use pools or policies.

Requirement #2: Only change the requests coming in where the path starts with /authorize (e.g. gets redirected). Other requests hitting the host with a different start to the path must remain unchanged (e.g. must stay the same).

Requirement #2: With a simple redirect, we want to change the host name only, and keep the paths in the redirect  the same as in the request and keep all query params and their values in the redirect the same as in the request (values change dynamically with each request)

2 Replies

  • The following should do the job:

    when HTTP_REQUEST {
        if { [HTTP::uri] starts_with "/authorize/" } {
            HTTP::redirect "[HTTP::uri]"


    [HTTP::uri] captures the entire URI path, ex.


    HTTP::path] captures the URI without the querystring, ex.


     [HTTP::query] captures just the querystring, ex.

  • Are u able to explaine why "Requirement #1: we can't use pools or policies." ?
    I recommend everyone to use LTM Policys instead of iRule wherever its possible.

    But Kevin_Stewart has the solution for iRule based redirect 🙂