Forum Discussion

Shailaja_V_3165's avatar
Shailaja_V_3165
Icon for Nimbostratus rankNimbostratus
May 15, 2017

Irule redirect without changing the original URL

Hello, I have a requirement to write a irule to redirect from one URL to another however the client should be able to see original URL only.

 

Example :

 

should be redirected to When client tries to access , he should see only. However at the back end the content should serve from .

 

I tried this with the standard HTTP::redirect but that also changes the URL field in the browser. eg:

 

when HTTP_REQUEST { if { [HTTP::path] contains "; } { HTTP::redirect "; } }

 

Could you please help. Thank you.

 

  • I tried using below format however the content shown in http: is not same as which is seen in http://www.abc.com

     

    when HTTP_REQUEST { if { [HTTP::header host] eq "http:; } { HTTP::header replace Host "; } }

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    An HTTP redirect, by nature, involves a URL change, i.e. instructing the user browser to go to another URL.

     

    What you need is to pass the client request traffic for to . You can set up a virtual server with a server pool containing for this purpose.

     

  • Hi,

    A little explanation about commands:

    when a user access URL http://www.123.com/browse.def?user=titi the real HTTP request is:

     

    GET /browse.def?user=titi HTTP/1.1
    Host: www.123.com
    User-Agent: myuseragent
    Some other headers: headers values
    

     

    Then, the following commands return this :

    • HTTP::path : /browse.def
    • HTTP::uri : /browse.def?user=titi
    • HTTP::query : user=titi
    • HTTP::host :

    You can try the following code to change hostname:

     

    when HTTP_REQUEST { 
         if { [HTTP::host] equals "www.123.com" } { 
            HTTP::host "www.abc.com" 
         } 
     }