Replace HTTP GET URL

Dear Expert,

I want to achieve the following scenario:

  1. A HTTP request coming to F5 (http://10.10.10.10/yo1/yo?http://youtube.com/watch?v=Di_stZgzdSw
  2. F5 replace the HTTP URL into http://youtube.com/watch?v=Di_stZgzdSw

I created the following but doesn’t seems working.

WHEN HTTP_Request {
if {[string tolower [HTTP::host]] starts_with “10.10.10.10”} {
    set Original_URL [URI::query [HTTP::uri]]
    set Original_URL2 [HTTP::query]
    HTTP::request replace $Original_URL2
    pool Server-10
}
}

Any advise?

Thanks.

try this (logging added so you can see what’s going on in the /var/log/ltm file)

when HTTP_REQUEST {
    log local0. "HOST: [HTTP::host]"
     If you're only using IP, you don't need the 'string tolower' piece
    switch [HTTP::host] {
        "10.10.10.10" {
            log local0. "  URI: '[HTTP::uri]'"

             "HTTP::uri" doesn't include the "?" so we need to add it when doing URI query parsing
            set redir [URI::query "?[HTTP::uri]" yo] 
            log local0. "  YO: $redir"
            if { !($yo equals "") } {
                log local0. "  Redirecting to '$redir'"
                HTTP::redirect $redir
                return
            }
        }
    }
}