Forum Discussion

John_Heyer_1508's avatar
John_Heyer_1508
Icon for Cirrostratus rankCirrostratus
Aug 09, 2017

iRule Variables and Connection Re-Use

I have an iRule that does 301 redirects within the same site, and have noticed when the client reuses the connection the variables seem to not be re-initialized.

 

when HTTP_REQUEST {
    set HOST [HTTP::host]
    set PATH [HTTP::path]

    if { [class match $PATH eq www_redirects] } {
      set ACTION "redirect"
      set VALUE [class match -value $PATH equals www_redirects]
    }
    if { [info exists ACTION] } {
      if { $ACTION eq "redirect" } {
        HTTP::respond 301 "Location" "https://$HOST$VALUE"
      }
    }
}

 

The browser does a wget to https://mysite.com/old it gets redirect to https://mysite.com/new as expected. But then gets redirect to https://mysite.com/new, https://mysite.com/new, https://mysite.com/new etc

Logging shows that $ACTION is still being set to "redirect" on the subsequent requests, so it's as if it's not being re-initialized when the new HTTP request comes in.