Forum Discussion

Joe_Pipitone's avatar
Joe_Pipitone
Icon for Nimbostratus rankNimbostratus
Jan 28, 2010

Redirects /rewrites not being caught

I have an iRule written that is supposed to catch the following URL's and redirect them all to https://www.oursite.org

The irule only seems to want to catch the first one, and it is not redirecting / rewriting the ones below that all begin with /Forms

Can anyone help me figure out why it won't catch the others and rewrite properly?

when HTTP_REQUEST {   
     switch [string tolower [HTTP::path]] {   
       "/login/default-login.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       }  
       "/forms/buy.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       } 
      "/Forms/ChangeForm.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       }  
      "/Forms/RegistrationForm.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       } 
      "/Forms/ChangePassword.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       }  
      "/Forms/RenewForm.aspx" {   
         HTTP::redirect "https://www.oursite.org[HTTP::uri]"   
       }  
     }   
   } 
 

2 Replies

  • I figured this out - I had to put everything to lower case and it all worked.
  • Nice work. Debug logging could help you catch something like that. Also, if the action is the same for any switch condition, you can combine them into one case:

     
     when HTTP_REQUEST { 
        switch [string tolower [HTTP::path]] { 
           "/login/default-login.aspx" - 
           "/forms/buy.aspx" - 
           "/forms/changeform.aspx" - 
           "/forms/registrationform.aspx" - 
           "/forms/changepassword.aspx" - 
           "/forms/renewform.aspx" - 
              HTTP::redirect "https://www.oursite.org[HTTP::uri]" 
           } 
        } 
     } 
     

    Aaron