Forum Discussion

southern_shred1's avatar
Icon for Nimbostratus rankNimbostratus
Jun 08, 2018

iRule Redirect loop



I am trying to achieve a simple URL redirect but I keep getting a redirect loop or nothing at all. I get an error of "too many redirects"


Condition 1


All requests to "; must be redirected to only


But any other traffic eg. "; must continue to the default pool


My problem is when I use the the irule below I get a redirect loop


when HTTP_REQUEST { if { [HTTP::host] equals "" } { HTTP::redirect " [HTTP::uri]" } }


When I try this it doesnt seem to work either. I know I am missing something


when HTTP_REQUEST { if { [HTTP::uri] equals ""} { HTTP::redirect "/Trace123" } elseif { [HTTP::uri] equals "; } { pool pool_trace123 } }


2 Replies

  • JG's avatar
    Icon for Cumulonimbus rankCumulonimbus

    Not totally sure of your requirement, but I will still a venture a reply, if only serving as a pointer:

    when HTTP_REQUEST {
        if { [HTTP::host] equals "" } {
            switch -exact [string tolower [HTTP::path]] {
                "/" {
                         HTTP::redirect ""
                default {
                            pool pool_trace123

    An LTM policy would actually be a better option, and its building process would guide you through it in a more transparent way and therefore be helpful to you.


  • Hi,


    if the virtual server only provides service for host, use following code :


    when HTTP_REQUEST {
        if {[HTTP::path] equals "/" } {
            HTTP::redirect "/Trace123"

    else you must filter on the host header


    when HTTP_REQUEST {
        if { [HTTP::host] equals "" && [HTTP::path] equals "/" } {
            HTTP::redirect "/Trace123"

    if not required by hostname change or protocol change (http to https redirect), please use "relative URL absolute path" URI in redirect (without protocol and host, but full path)