Forum Discussion

OliverS_221234's avatar
OliverS_221234
Icon for Nimbostratus rankNimbostratus
Sep 21, 2015

Redirect URL with URL attached

Hi,

 

I'm new to F5 and have a question regarding URL redirect. The task is to change the server URL but leave the URL path untouched. An example would be:

 

redirect www.company.de/abc/xyz/ to www.company.com/abc/xyz/

 

Is there any way how I can achieve this? Right now I'm simply redirecting the domain part of the URL, but any user is then redirected to the main page instead of the requested URI.

 

My iRule looks like

 

when HTTP_REQUEST { if {[HTTP::host] equals "some.company.de"} { HTTP::redirect "https://some.company.com" } }

 

Any suggestion is appreciated. Best regards,

 

Oliver Stock

 

2 Replies

  • Hi,

    When requesting www.company.de/abc/xyz/ the HTTP request is:

    GET /abc/xyz/?param1=value1&param2=value2 HTTP/1.1
    Host: www.company.de
    User-agent: Mozilla...
    Other-Headers
    

    When working with HTTP:

    • www.company.de is HTTP Host : variable [HTTP:host]
    • /abc/xyz/?param1=value1&param2=value2 is the uri : variable [HTTP:uri]
    • /abc/xyz/ is the path : variable [HTTP:path]
    • param1=value1&param2=value2 is the query string : variable [HTTP:query]

    Try the following irule:

    when HTTP_REQUEST { 
        if {[string tolower [HTTP::host]] equals "some.company.de"} { 
            HTTP::redirect "https://some.company.com[HTTP::uri]" 
        } 
    }
    
  • Hi Stanislas,

     

    we've tested your proposal, and it works fine. Thanks a lot for your help, it was really appreciated. Best regards,

     

    Oliver Stock