Forum Discussion

jgoetsch_236444's avatar
jgoetsch_236444
Icon for Nimbostratus rankNimbostratus
Jun 24, 2016

URL Rewrite to another domain

Hi All,

 

I am attempting to perform a URL rewrite in our F5 BigIP load balancer. This needs to be a URL rewrite to another domain, redirects will not work. I have attempted the following but it is currently not working, it simply directs the request to IIS without performing the rewrite.

 

when HTTP_REQUEST { if { ( $low_uri equals "/test-page" ) or ( $low_uri equals "/test-page/" )} then { HTTP::header replace "Host" "test.example.com" } }

 

Thank you,

 

Jason

 

1 Reply

  • Client sends "abcd.com", it is changed to "xyz.com" and sent to servers. Reply from servers is "xyz.com" and it is changed to "abcd.com" and sent to clients.

    Use this as an example and modify it to suit your requirements:

    when HTTP_REQUEST {
    if { [HTTP::host] contains "abcd.com" } {
    HTTP::host [string map {abcd.com xyz.com} [HTTP::host]] 
    }
    
    when HTTP_RESPONSE {
    if { [HTTP::header values Location] contains "xyz.com" } {
    HTTP::header replace Location [string map {xyz.com abcd.com} [HTTP::header value Location]]
    }
    }