Forum Discussion

Mitch_Ryan_6222's avatar
Mitch_Ryan_6222
Icon for Nimbostratus rankNimbostratus
May 27, 2008

HTTP redirect

Hello,

 

I am trying to create a simple redirect such that our users can type abc.com and be redirected to: xyz.com:9091/path-to-database

 

 

I have tried borrowing iRule code from other posts:

 

when HTTP_REQUEST {

 

if { [HTTP::uri] equals "/"} {

 

HTTP::redirect "http://abc.com/path-to-database"}

 

}

 

 

This will not work - it generates a 'Page cannot be displayed' error. If I change the abc.com to xyz.com:9091 in the iRule then it will work but the user will see the real server name and port number in their address bar, which is not the desired behavior.

 

I also tried substituting the HTTP::redirect line with:

 

HTTP::redirect http://[HTTP::host][HTTP::uri]

 

 

BTW - abc.com has been set up in DNS and will resolve to the IP address of the virtual server on the F5. The F5's virtual server is set up to use a pool called abc, and this pool has the service port defined as 9091.

 

 

Perhaps this isn't an iRule problem and actually indicates some other configuration issue, and if so, then I apologize for posting here.

 

 

Mitch
  • If I understood correctly, you don't actually want to do a redirect but instead replace the URI "/" in incoming requests with "/path-to-database" and then take the user to the Virtual Server's default pool (abc). If this is the case, try this:

     
     when HTTP_REQUEST { 
       if {[HTTP::uri] equals {/}} { 
         HTTP::uri {/path-to-database} 
       } 
     } 
     
  • From the post it looks like u want to redirect abc.com to xyz.com so is this xyz.com also configured on same bigip and registered ?
  • In response to rajwinder:

     

    Yes, xyz.com is defined on the same bigip and is registered, has a self-IP address, etc.

     

     

    In response to Ikatona:

     

    That seems to work. I can't believe how simple that was.

     

    Thanks.