Forum Discussion

mikey_webb's avatar
Oct 28, 2020

Geolocation irule multiple redirect error

i have the below redirect based on geolocation which seems to work. however in the f5 log i see operation not support multiple redurect error-assume issue is with the default at the end, so question is how to do geolocation with a catch all default?.

 

 

when HTTP_REQUEST {

   set country "[whereis [IP::client_addr] country]"

 

   if { $country equals "GB" } {

       HTTP::redirect "https://uk.abc.com/"

       return

   }

   elseif { $country equals "AU" } {

       HTTP::redirect "https://intl.abc.com/aus"

       return

   }

   elseif { $country equals "US" } {

       HTTP::redirect "https://intl.abc.com/usa"

       return

   }

   elseif { $country equals "CA" } {

       HTTP::redirect "https://intl.abc.com/can"

       return

   }

   else

   {

   HTTP::redirect "https://uk.abc.com/"

   }

}

1 Reply

  • Hi mikey_webb,

    Can you try using "HTTP::has_responded"?

    when HTTP_REQUEST {
    	if { HTTP::has_responded } { return }
    	switch [whereis [IP::client_addr] country] {
    		"GB" {
    			HTTP::redirect "https://uk.abc.com/"
    			return
    		}
    		"AU" {
    			HTTP::redirect "https://intl.abc.com/aus"
    			return
    		}
    		"US" {
    			HTTP::redirect "https://intl.abc.com/usa"
    			return
    		}
    		"CA" {
    			HTTP::redirect "https://intl.abc.com/can"
    			return
    		}
    		default {
    			HTTP::redirect "https://uk.abc.com/"
    			return
    		}
    	}
    }