Forum Discussion

gkorah_32913's avatar
gkorah_32913
Icon for Nimbostratus rankNimbostratus
Sep 16, 2010

iRule for HTTP redirect

I am able to get http redirect working for a FQDN (eg - www.xyz.com), which I have it set to go to www.abc.com

 

 

The issue I run into is that the redirect to www.abc.com also works when the path has a path following in the FQDN, for eg like www.xyz.com\workspace\default.asp. This also gets redirected to www.abc.com.

 

 

How can i setup my iRule to allow http redirect to www.abc.com only if the request is to www.xyz.com, everything else follows the same original URL path.

 

 

Please advise & thanks in advance.

 

 

--

 

GK

 

  • Which of the following are you trying to do:

    1. Only when a user hits "www.xyz.com", redirect them to "www.abc.com"

    2. When a user hits "www.xyz.com/sample", redirect them to "www.abc.com/sample"

    This would handle number 1:

    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] eq "www.xyz.com" and [string tolower [HTTP::uri]] eq "/" } {
    HTTP::redirect "http://www.abc.com" } }
    

    This would handle number 2:

    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] eq "www.xyz.com" } {
    HTTP::redirect "http://www.abc.com[HTTP::uri]" } }
    

  • Chris - Thx for the info. This is what I want to do -

     

     

    If a user types in www.xyz.com, I am able to redirect that to www.abc.com. No issues there.

     

     

    When the same user types in www.xyz.com/sample, i want the session to continue to the same URL, www.xyz.com/sample, instead of getting redirected to www.abc.com
  • Posted By gkorah on 09/16/2010 08:44 AM

     

    Chris - Thx for the info. This is what I want to do -

     

     

    If a user types in www.xyz.com, I am able to redirect that to www.abc.com. No issues there.

     

     

    When the same user types in www.xyz.com/sample, i want the session to continue to the same URL, www.xyz.com/sample, instead of getting redirected to www.abc.com

     

     

    The first rule should accomplish that.
  • FYI-when referring to the "path" after a FQDN, this is typcally called the "uri"

     

     

    just thought it might help to understand the rule a lil better...