Forum Discussion

Anil_Gupta_01_1's avatar
Anil_Gupta_01_1
Icon for Nimbostratus rankNimbostratus
Oct 06, 2016

http request re-write

Hi,

I need help to rewrite the http request for below requirement.Request your help. I was trying below irule; but it is not working.

Original request on F5 VIP

https://xyz.com/sme/mobile-webconsole

Need to rewrite to below URL before request send to pool member

https://xyz.com/mobile-webconsole

when HTTP_REQUEST {

if { ([HTTP::host] equals "xyz.com") and ([HTTP::path] equals "/sme/mobile-webconsole") } {

    HTTP::path "/mobile-webconsole"
}

}

Regards, Anil

2 Replies

  • HTTP::path
    should be fine for the rewrite, and generally, is preferred (since it maintains any request parameters). I recommend adding logging, as in:

    when HTTP_REQUEST {
        log local0. "host = [HTTP::host]; path = [HTTP::path]"
        
        if { [string tolower [HTTP::host]] eq "xyz.com" and [HTTP::path] eq "/sme/mobile-webconsole" } {
            log local0. "  .. matches"
            HTTP::path "/mobile-webconsole"
        }
    }
    

    to see what's going on.