Forum Discussion

abachman_72712's avatar
abachman_72712
Icon for Nimbostratus rankNimbostratus
Aug 12, 2009

Redirect to URL

Attempting to script an iRule a redirect statement for a URL, but I cannot get the iRule statement to take. We would like users to type in the browser http://testsite, and have them redirected to http://testsite/test/sitedoc.do. I need to add this statement into the already existing iRule that is attached to a persistence profile.

 

 

when CLIENT_ACCEPTED {

 

set add_persist 1

 

}

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {

 

persist add uie [HTTP::cookie "JSESSIONID"]

 

set add_persist 0

 

}

 

}

 

when HTTP_REQUEST {

 

if { [TCP::local_port] == 80 }{

 

HTTP::redirect http://testsite/test/sitedoc.do

 

}

 

if { [HTTP::cookie exists "JSESSIONID"] } {

 

persist uie [HTTP::cookie "JSESSIONID"]

 

} else {

 

set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]

 

if { $jsess != "" } {

 

persist uie $jsess

 

}

 

}

 

if {not ([HTTP::uri] starts_with "/ClaimCenter/ClaimCenter.do")}{

 

HTTP::uri "/ClaimCenter/ClaimCenter.do[HTTP::uri]"

 

}

 

}

 

 

{

 

}

 

}

 

 

Any help would be appreciated

 

 

  • The last few lines of the previous iRule were removed, and should not have been there. Here is the real syntax of the iRule being applied.

     

     

     

    when CLIENT_ACCEPTED {

     

    set add_persist 1

     

    }

     

    when HTTP_RESPONSE {

     

    if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {

     

    persist add uie [HTTP::cookie "JSESSIONID"]

     

    set add_persist 0

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    if { [TCP::local_port] == 80 }{

     

    HTTP::redirect http://testsite/test/sitedoc.do

     

    }

     

    if { [HTTP::cookie exists "JSESSIONID"] } {

     

    persist uie [HTTP::cookie "JSESSIONID"]

     

    } else {

     

    set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]

     

    if { $jsess != "" } {

     

    persist uie $jsess

     

    }

     

    }

     

    }

     

     

    {

     

    }

     

    }