Forum Discussion

Joe_Pipitone's avatar
Joe_Pipitone
Icon for Nimbostratus rankNimbostratus
Jul 29, 2010

[SOLVED] iRule redirect loop problem

I have an iRule which is only partially working. Can anyone tell me why putting the following in place results in a redirect loop? It does the job partially by stripping the www, however if you try to browse to oursite.com/salarysurvey or oursite.com/salarysurveys it results in a redirect loop.


when HTTP_REQUEST { 
if { ([HTTP::host] eq "www.oursite.com") } { 
    HTTP::redirect "http://oursite.com[HTTP::uri]"
    return
    }
    switch -glob [string tolower [HTTP::uri]] { 
       "/salarysurvey" -
       "/salarysurvey/" {
        HTTP::redirect "http://oursite.com/salarysurveys/"
        return
    }
        "/salarysurveys" -
        "/salarysurveys/" {
        HTTP::redirect "http://oursite.com/salarysurveys/" 
        return
    }
        "/images*" {
         HTTP::redirect "http://legacy.oursite.com[HTTP::uri]"
         return
    }
  }
}

5 Replies

  • Unless I'm missing something - this would do this in a much easier fashion.

    
    when HTTP_REQUEST { 
       switch -glob [string tolower [HTTP::uri]] {
           "/salarysurvey" - 
           "/salarysurvey/" -
           "/salarysurveys" -
           "/salarysurveys/"  { HTTP::redirect "http://oursite.com/salarysurveys/" }         
           "/images*" { "http:://legacy.oursite.com[HTTP::uri]" } }
     if { [HTTP::host] eq "www.oursite.com" } {
       HTTP::redirect "http://oursite.com[HTTP::uri]" }
    }
    
  • Same thing, still results in a redirect loop that will never finish according to Firefox and Chrome - IE doesn't even display the page at all. Any ideas?
  • The reason for the redirect loop - for some reason the F5 didn't like the fact that I was trying to catch /salarysurveys and /salarysurveys/ - as soon as I removed the one with the trailing slash, it started working fine.

     

     

    Also, your syntax above broke the rewriting for /images* but I appreciate your help!

     

     

  • Posted By Joe Pipitone on 07/29/2010 01:55 PM

     

    The reason for the redirect loop - for some reason the F5 didn't like the fact that I was trying to catch /salarysurveys and /salarysurveys/ - as soon as I removed the one with the trailing slash, it started working fine.

     

     

    Also, your syntax above broke the rewriting for /images* but I appreciate your help!

     

     

     

     

    Doh - been a very long week, shoulda noticed we were redirecting our own redirect :-P GLad to hear it's working for you.