Forum Discussion

Michael_Sproul1's avatar
Michael_Sproul1
Icon for Nimbostratus rankNimbostratus
Nov 08, 2019

URL client-side Redirect with URI intact

URL site1.xxx.gov directs in DNS to VirtualServer1 and goes to a default pool. URL site2.xxx.gov currently directs in DNS to VirtualServer2 and goes to a different default pool. Customer has requested that the LTM do a client-side redirect back to the client so that site2.xxx.gov ends up being rewritten as site1.xxx.gov, with the URI remaining unchanged, so that the traffic will flow to the VirtualServer1 path, and reach the default pool with the site1.xxx.gov URL and the original URI. Can't just do it in DNS, as he wants it to show up on the servers as site1.

1 Reply

  • This hasn't been tested but roughly a framework for you to refine it. You would have to use this on the VS serving site2.com:

    when HTTP_REQUEST { 
    if { [HTTP::host] equals "site2.com" } { 
    HTTP::header replace "Host" "site1.com"
    virtual site1_Virtual-Server
    return 
    } 
    }

    This would have to go in the virtual server for site1.com:

    when HTTP_RESPONSE {
    if { [HTTP::header values Location] contains "site1.com" } {
    HTTP::header replace Location [string map {"site1.com" "site2.com"} [HTTP::header value Location]]
    }
    }