Forum Discussion

Jules_M__Green's avatar
Jules_M__Green
Icon for Nimbostratus rankNimbostratus
Oct 28, 2019

Multiple errors with redirect iRule referencing data groups that was previously working

I am having a strange problem with an iRule that was working fine, and a few days later it is giving me multiple errors and I cannot pinpoint why. I want to note that the redirect looks to be working in IE, but not in Chrome or Firefox, which is also strange. This only seems to be giving an error when it is just a hostname, If it is host/uri, it is working, so the top section of the iRule is not executing when it was a few days ago.

 

There errors in the log (infoblox.chevron.com is in the correct data group):

 

  • Rule /Common/Chevron--Internal--Redirect_iRule <HTTP_REQUEST>: Redirect for 'infoblox.chevron.com/' was not found in data group 'chevron--internal--redirect' or 'chevron--internal--keepURI_redirect'  

 

  • TCL error: /Common/Chevron--Internal--Redirect_iRule <HTTP_REQUEST> - Operation not supported. Multiple redirect/respond invocations not allowed (line 29) invoked from within "HTTP::redirect http://www.404errorpages.com"  

 

The iRule (redirect path 404errorpages.com is just a temp path):

 

when HTTP_REQUEST {

  # log local0. "Host: [HTTP::host] and URI: [HTTP::uri]"

  if { [HTTP::uri] == "/" } {

  # searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> if found

  if { [class match [HTTP::host] equals chevron--internal--redirect] } {

      HTTP::respond 302 Location "[class match -value [HTTP::host] equals chevron--internal--redirect]"

    }

  else {

  # No match found log and redirect to error page

   log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was not found in data group 'chevron--internal--redirect'"

 HTTP::redirect http://www.404errorpages.com

 

    }

  }

  # searches for a hostname+uri match in datagroup and redirects to the hostname+uri match value <the redirect path> if found

    if { [class match [HTTP::host][HTTP::uri] equals chevron--internal--redirect] } {

  # log local0. "matched host and uri"

      HTTP::respond 302 Location "[class match -value [HTTP::host][HTTP::uri] equals chevron--internal--redirect]"

  }

  elseif { [class match [HTTP::host] equals chevron--internal--keepURI_redirect] } {

  # searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> while keeping the uri if found

# example: mysite.com/help redirects to yoursite.com/help 

  # log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was found in data group 'chevron--internal--keepURI_redirect'"

    set myuri [HTTP::uri]

    set myhost [class match -value [HTTP::host] equals chevron--internal--keepURI_redirect]

    HTTP::respond 302 Location "$myhost$myuri"

  }  

  else {

   log local0.info "Redirect for '[HTTP::host][HTTP::path]' was not found in data group 'chevron--internal--redirect' or 'chevron--internal--keepURI_redirect'"

 HTTP::redirect http://www.404errorpages.com

    }

  }

 

 

Any suggestions?

2 Replies

  • Hi Jules,

    Can you try this?

    I added else statement for "if { [HTTP::uri] == "/" }"

    when HTTP_REQUEST {
    	# log local0. "Host: [HTTP::host] and URI: [HTTP::uri]"
    	
    	if { [HTTP::uri] == "/" } {
    		# searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> if found
    		if { [class match [HTTP::host] equals chevron--internal--redirect] } {
    			HTTP::respond 302 Location "[class match -value [HTTP::host] equals chevron--internal--redirect]"
    		}
    		else {
    			# No match found log and redirect to error page
    			log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was not found in data group 'chevron--internal--redirect'"
    			HTTP::redirect http://www.404errorpages.com
    		}
    	}
    	else {
    	    # searches for a hostname+uri match in datagroup and redirects to the hostname+uri match value <the redirect path> if found
    		if { [class match [HTTP::host][HTTP::uri] equals chevron--internal--redirect] } {
    			# log local0. "matched host and uri"
    			HTTP::respond 302 Location "[class match -value [HTTP::host][HTTP::uri] equals chevron--internal--redirect]"
    		}
    		elseif { [class match [HTTP::host] equals chevron--internal--keepURI_redirect] } {
    			# searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> while keeping the uri if found
    			# example: mysite.com/help redirects to yoursite.com/help 
    			# log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was found in data group 'chevron--internal--keepURI_redirect'"
    			set myuri [HTTP::uri]
    			set myhost [class match -value [HTTP::host] equals chevron--internal--keepURI_redirect]
    			HTTP::respond 302 Location "$myhost$myuri"
    		} 
    		else {
    			log local0.info "Redirect for '[HTTP::host][HTTP::path]' was not found in data group 'chevron--internal--redirect' or 'chevron--internal--keepURI_redirect'"
    			HTTP::redirect http://www.404errorpages.com
    		}
    	}
    }
  • I think may have done it!! Thank you very much. Not sure why it was working fine previously, but I will test this further and should be good to go.