Forum Discussion

Joe_Pipitone's avatar
Joe_Pipitone
Icon for Nimbostratus rankNimbostratus
Apr 13, 2010

Big-ip syslog errors continue

After combining multiple redirect iRules into one master iRule, I'm still getting the following error in the big-ip logs. I was under the impression that having separate iRules with redirect statements would cause this, however I am now thinking it is because I'm using a switch statement with multiple cases. Can anyone help? Below is the error, followed by my gigantic iRule.

TCL error: my-rewrite-rule HTTP_REQUEST - Operation not supported. Multiple redirect/respond invocations not allowed 
line 192 invoked from within HTTP::redirect http://domain.com[HTTP::uri] default 
arm line 1 invoked from within switch -glob [HTTP::host] { / { HTTP::redirect 
http://domain.com } default { HTTP::redirect http://domain.com[HTTP::uri] } ...

ssl and marketing rewrites
when HTTP_REQUEST {
    switch [string tolower [HTTP::uri]] {  
      "/login/default-login.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      } 
      "/forms/buy.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      }
     "/forms/changeform.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      } 
     "/forms/registrationform.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      }
     "/forms/changepassword.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      } 
     "/forms/renewform.aspx" {  
        HTTP::redirect "https://domain.com[HTTP::uri]"  
      } 
     "/redirects/marketing/somepage.aspx?campaignid=2493" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      } 
     "/redirects/marketing/somepage.aspx?campaignid=2494" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      } 
     "/redirects/marketing/somepage.aspx?campaignid=2495" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2496" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      } 
     "/redirects/marketing/somepage.aspx?campaignid=2497" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2498" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2499" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2500" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2501" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2502" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2503" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaignid=2504" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      }
     "/redirects/marketing/somepage.aspx?campaigngroupid=17" {  
        HTTP::redirect "http://subdomain.domain.com/events/some-path-here/home.aspx"  
      } 
     "/membership/benefits*" { 
      HTTP::redirect "http://domain.com/pages/members/some-page.aspx" 
      } 
     "/poster*" { 
      HTTP::redirect "http://domain.com/pages/posters/some-page.aspx" 
      } 
     "/publications/poster.aspx" { 
      HTTP::redirect "http://domain.com/pages/posters/some-page.aspx" 
      } 
     "/orlando2009bi*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2463" 
      } 
     "/orlando2009bi/register*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2464" 
      } 
     "/orlando2009bi/hotel*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2465" 
      } 
     "/orlando2009bi/coursepreviews*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2466" 
      } 
     "/2009orlandobi*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2467" 
      }
     "/2009orlandobi/register*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2468" 
      }
     "/2009orlandobi/hotel*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2469" 
      }
     "/2009orlandobi/coursepreviews*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2470" 
      }
     "/or2009*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2471" 
      }
     "/ontheroad/dc09*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2472" 
      }
     "/ontheroad/09dc*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2473" 
      }
     "/ontheroad/09vancouver*" { 
      HTTP::redirect "http://domain.com/Redirects/Marketing/somepage.ASPX?CampaignId=2474" 
      }
     "/whatworks27wp*" { 
      HTTP::redirect "http://domain.com/Publications/ww27whitepapers.aspx" 
      }
     "/whatworks28wp*" { 
      HTTP::redirect "http://domain.com/Publications/ww28whitepapers.aspx" 
      }
     "/lv2010/instructors*" { 
      HTTP::redirect "http://events.domain.com/events/speakers/speaker-list.aspx" 
      } 
     "/lv2010/hotel*" { 
      HTTP::redirect "http://events.domain.com/events/information/hotel-and-travel.aspx" 
      } 
     "/lv2010/register*" { 
      HTTP::redirect "http://events.domain.com/events/information/registration.aspx" 
      } 
     "/lv2010/fax*" { 
      HTTP::redirect "http://events.domain.com/events/information/registration.aspx" 
      } 
     "/lasvegas10*" { 
      HTTP::redirect "http://events.domain.com/events/home.aspx" 
      } 
     "/lv2010" {
      HTTP::redirect "http://events.domain.com/events/home.aspx" 
      }
     "/lv2010/" {
      HTTP::redirect "http://events.domain.com/events/home.aspx" 
      }
     "/lasvegas2010*" { 
      HTTP::redirect "http://events.domain.com/events/home.aspx" 
      }  
     "/lv2010/es/register*" { 
      HTTP::redirect "http://events.domain.com/events/information/registration.aspx" 
      } 
     "/lv2010/es/hotel*" { 
      HTTP::redirect "http://events.domain.com/events/information/hotel-and-travel.aspx" 
      } 
     "/lv2010/es/qualify*" { 
      HTTP::redirect "http://events.domain.com/events/information/qualification.aspx" 
      } 
     "/lv2010/es*" { 
      HTTP::redirect "http://events.domain.com/events/home.aspx" 
      }
     "/education/seminars/index.aspx" { 
      HTTP::redirect "http://events.domain.com/events/some-path/home.aspx" 
      } 
     "/seminars/boston*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/boston-seminar.aspx" 
      } 
     "/seminars/seattle*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/seattle-seminar.aspx" 
      }
     "/seminars/minneapolis*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/minneapolis-seminar.aspx" 
      }
     "/seminars/denver*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/denver-seminar.aspx" 
      }
     "/seminars/toronto*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/toronto-seminar.aspx" 
      }
     "/seminars/dc*" { 
      HTTP::redirect "http://events.domain.com/events/some-path/information/washington-dc-seminar.aspx" 
      }   
    }

another subdomain rewrite
switch [string tolower [HTTP::path]] {  
   "/info.aspx" {  
        HTTP::redirect "http://subdomain.ourdomain.com/default.aspx?[HTTP::query]"  
      }
   }   

legacy rewrite
if {[HTTP::uri] starts_with "/admin" } {
        HTTP::redirect "http://legacy.domain.com[HTTP::uri]"
      }

strip www
if { ([HTTP::host] eq "www.domain.com") } { 
        switch -glob [HTTP::host] { 
          "/" { HTTP::redirect "http://domain.com" }
             default {  HTTP::redirect "http://domain.com[HTTP::uri]" }
        } 
    } 
}

6 Replies

  • Hi Joe,

     

     

    I'd suggest adding the all of the redirects to a single switch. You could have a nested switch if you wanted to. The key is to make sure that a single request will only trigger a redirect once. In other words, how would you want to handle a request for www.domain.com/admin? Currently, this would match both your checks for a URI starting with /admin as well as the check for a host of www.domain.com.

     

     

     

    Or you could exit the HTTP_REQUEST once you've done one redirect using the 'return' command. But I think it's better to consider the different cases where you'd want to issue a redirect and code them explicitly.

     

     

    Aaron
  • The problem with combining all of the redirect statements into the switch is - see my comment towards the bottom of the script - another subdomain rewrite. If I combine this one with the others above, the redirect only half works. It rewrites the url but does not pass along the uri query string as part of the full url. Unless I use the http::path, it won't work.

     

     

    Perhaps I will try exiting the HTTP_REQUEST once I've done one redirect.
  • Can anyone help with syntax of exiting the HTTP_REQUEST? Or point me in the right direction as far as where to find big-ip docs for this syntax?
  • Hi Joe,

     

     

    When you say the redirect doesn't pass on the query string, can you clarify what you mean? As long as the redirect includes the HTTP::query command, LTM should append the requested query string to the redirect.

     

     

    If you wanted to add the HTTP::path check to the switch which uses HTTP::uri, you could use the lines below. It looks for a URI of exactly "/info.aspx" or "/info.asp?" followed by anything. Either match would result in a redirect to the URL below with the original query string appended.

     

     

    switch -glob [string tolower [HTTP::uri]] {
       ...other checks...
       "/info.aspx" -
       "/info.aspx\?*" {
          HTTP::redirect "http://subdomain.ourdomain.com/default.aspx?[HTTP::query]"  
       }
    }
    

     

    Note that I've added the -glob flag to the switch so that wildcards can be used in the switch cases.

     

    You can also add a default case to the main switch statement which will run if no prior match is found. In that default switch case, you can check for the legacy rewrite and 'strip www from host' code.

     

     

    if {[HTTP::uri] starts_with "/admin" } {
       HTTP::redirect "http://legacy.domain.com[HTTP::uri]"
    } elseif {[string tolower [HTTP::host]] eq "www.domain.com"}{
       HTTP::redirect "http://domain.com[HTTP::uri]"
    }
    

     

     

    Note that I've changed the 'strip www from domain' code slightly as both cases in your switch were doing the same thing.

     

     

    Does this make sense and look like it would work for you?

     

     

    Aaron
  • For example, this code below will not carry over the query if i change HTTP::path to HTTP::uri. It simply rewrites to default.aspx with no query appended.

     

     

    
    switch [string tolower [HTTP::path]] {  
       "/info.aspx" {  
            HTTP::redirect "http://subdomain.ourdomain.com/default.aspx?[HTTP::query]"  
          }
       } 
    

     

     

    http://domain.com/info.aspx?id=4453 is supposed to be rewritten as http://subdomain.ourdomain.com/default.aspx?id=4453, however it is actually rewritten as http://subdomain.ourdomain.com/default.aspx. This is why I had to separate the rule and incorporate HTTP::path.

     

     

    Thanks for your suggestions above, I will give those a shot and post my results.
  • Wow - your trickery works like a charm - thank you very very very much for the help, I can finally put this to bed!