Forum Discussion

Danny_Trinh_197's avatar
Danny_Trinh_197
Icon for Nimbostratus rankNimbostratus
Jan 11, 2009

Redirect test.example.com to test.example.com/abc/def/gh...i

I searched this forum but couldn't find the answer, and I'm kind new to F5.

 

What can I do to redirect:

 

this url: http://test.example.com

 

to:

 

http://test.example.com/abc/def/ghi/jkl/mno/

 

 

I found this below, but I got an error of looping:

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] equals "webclient.example.com" } {

 

HTTP::redirect "http://webclient.example.com/abc/def/ghi/jkl/mno/"

 

}

 

}

 

 

 

Thanks,

3 Replies

  • You can add a check of the URI so you're only redirecting clients who make a request to the root (/):

     
     when HTTP_REQUEST { 
        if { [string tolower [HTTP::host]] eq "webclient.example.com" && [HTTP::path] eq "/" } { 
           HTTP::redirect "http://webclient.example.com/abc/def/ghi/jkl/mno/" 
        } 
     }  
     

    Aaron
  • It's work great. Thanks,

     

     

    Another question:

     

    What can I add to this iRule so it doesn't matter what the client type (http://webclient.example.com; https://webclient.example.com; or just webclient.example.com), it always redirect to http://webclient.example.com/abc/def/ghi/jkl/mno/?

     

     

    Thanks in advance,
  • The host header value doesn't include the protocol, so this iRule would work for HTTP or HTTPS. If you have an HTTP VIP and an HTTPS VIP, you can use this iRule on both VIPs.

     

     

    Aaron