Forum Discussion

Daric_Smith's avatar
Daric_Smith
Icon for Nimbostratus rankNimbostratus
Jun 17, 2019

HTTP redirect to full URL Path

We have a URL that we would like to redirect from a friendly name to a full path.

 

Example: taking http://application.bob.com and redirecting it to the back-end node's URL: http://back_end_node/application_path.

1 Reply

  • Do you want a redirect, i.e. HTTP redirect sent back to client, or are you looking to rewrite the hostname and path on the F5 before forwarding traffic on to the backend servers?

    Also you want to redirect/forward to add uri on, e.g. http://application.bob.com/app1 to http://back_end_node/application_path/app1

    Redirect:

    when HTTP_REQUEST {
        if {[getfield [HTTP::host] : 1]  eq "application.bob.com"} {
            HTTP::redirect "http://back_end_node/application_path[HTTP::uri]"
        }
    }

     Forward:

    when HTTP_REQUEST {
        if {[getfield [HTTP::host] : 1] eq "application.bob.com"} {
            HTTP::header replace "Host" "back_end_node"
            HTTP::uri "/application_path[HTTP::uri]"
        }
    }