Forum Discussion

Zuke's avatar
Zuke
Icon for Cirrostratus rankCirrostratus
Aug 04, 2021
Solved

Simple HTTP::redirect iRule results in a reset

I first tried doing this with a policy but that didn't work. When I added this iRule, both the customer and I tested and it worked fine. Now I'm getting error messages.

Professor X's website "professorx.xmen.com" is moving to "https://www.xmen.com/professorx"

There are multiple hosts that are moving to this virtual server, so I wanted to switch on the host and do the redirects. When I add a log message, it shows the $hostLowered as "professorx.xmen.com"

when HTTP_REQUEST priority 1 {
    set host [HTTP::host]
    set hostLowered [string tolower $host]
    set uri [HTTP::uri]
    set uriLowered [string tolower $uri]
    
    switch -glob -- $hostLowered
    {
    "professorx.*"   { 
        HTTP::redirect "https://www.xmen.com/professor-x-website"
    }
  } 
}

  • Fixed by adding event disable after the redirect