Forum Discussion

Stuart_Feather1's avatar
Stuart_Feather1
Icon for Nimbostratus rankNimbostratus
Sep 23, 2014
Solved

iRule error - Multiple redirect/respond invocations not allowed

I have an existing iRule that redirects any requests to our root site (http://abc.com) to be redirected to www.abc.com. Simplified example of the iRule below.

 

when HTTP_REQUEST { if { ([HTTP::host] equals "abc.com" ) } { HTTP::respond 301 Location "http://www.abc.com[HTTP::uri]" }

 

This iRule has been working fine. I had a new request today that requets to specific web pages that have been removed should be 301 redirected to the new pages that replaced the old pages. Simplified example of the iRule below.

 

when HTTP_REQUEST { switch [HTTP::uri] { "/Page1.php" { HTTP::respond 301 Location "http://www.abc.com/Page1.aspx" } "/Page2.php" { HTTP::respond 301 Location "http://www.abc.com/Page2.aspx" } default { don't do anything... } } }

 

These are 2 separate iRules and the order they are listed on the Virtual Server is the same as I have the examples listed above.

 

The redirects work correctly, but I do get an error that says " - Operation not supported. Multiple redirect/respond invocations not allowed." in certain instances. When a request comes in for http://abc.com/page1.php the iRule is trying to redirect to http://www.abc.com/page1.php and then http://www.abc.com/page1.aspx which is actually 2 redirects in a single request.

 

Is there a way I can modify the iRule to prevent this error? I'm not sure how to fix this, but I'm wondering if it is possible that after the first redirect is issued, can I have the 2nd iRule not process until the request comes back through after the redirect to the www name? Is there a better way to accomplish this?

 

Thanks in advance!

 

  • Since the logic is somewhat related (redirect logic), why not merge the two iRules into something like:

    when HTTP_REQUEST {
        switch [HTTP::uri] {
        "/Page1.php" {
         HTTP::respond 301 Location "http://www.abc.com/Page1.aspx" 
         } 
    
         "/Page2.php" { 
         HTTP::respond 301 Location "http://www.abc.com/Page2.aspx" 
         } 
    
         default { 
          if { ([HTTP::host] equals "abc.com" ) } {
             HTTP::respond 301 Location "http://www.abc.com[HTTP::uri]" 
            } 
         }
        }
    }
    

4 Replies

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    Since the logic is somewhat related (redirect logic), why not merge the two iRules into something like:

    when HTTP_REQUEST {
        switch [HTTP::uri] {
        "/Page1.php" {
         HTTP::respond 301 Location "http://www.abc.com/Page1.aspx" 
         } 
    
         "/Page2.php" { 
         HTTP::respond 301 Location "http://www.abc.com/Page2.aspx" 
         } 
    
         default { 
          if { ([HTTP::host] equals "abc.com" ) } {
             HTTP::respond 301 Location "http://www.abc.com[HTTP::uri]" 
            } 
         }
        }
    }
    
  • Since the logic is somewhat related (redirect logic), why not merge the two iRules into something like:

    when HTTP_REQUEST {
        switch [HTTP::uri] {
        "/Page1.php" {
         HTTP::respond 301 Location "http://www.abc.com/Page1.aspx" 
         } 
    
         "/Page2.php" { 
         HTTP::respond 301 Location "http://www.abc.com/Page2.aspx" 
         } 
    
         default { 
          if { ([HTTP::host] equals "abc.com" ) } {
             HTTP::respond 301 Location "http://www.abc.com[HTTP::uri]" 
            } 
         }
        }
    }
    
    • Stuart_Feather1's avatar
      Stuart_Feather1
      Icon for Nimbostratus rankNimbostratus
      I think that sounds like a good idea, I'll give that a try. Thanks shaggy!