Forum Discussion

rob_miller_7792's avatar
rob_miller_7792
Icon for Nimbostratus rankNimbostratus
Nov 01, 2007

Nested iR not working?

I am trying to implement a nested iRule, and was hoping to get some help on my syntax.

 

 

I am trying to accomplish 2 things. First, if the user enters mydomain.com or x.mydomain.com then I need to redirect them to www.mydomain.com. this is keep the cookies consistent on the customers machine.

 

 

second, I am also using this iRule to redirect to a secure connection for any secure pages on our site.

 

 

I have 2 iRules that accomplish this on their own, but whenever I try to combine them the browser just clocks, so I assume it is stuck redirecting over and over. here is the code I have tried that seems to me like it should work:

 

 


if (http_host contains one of ValidDomains){
   if (substr(http_uri, 1, '?') contains one of SecurePages) {
      redirect to "https://%h/%u"
   }
   else {
      use pool mywebfarm
   }
}
else {
   redirect to "http://www.mydomain.com/%u"
}

 

 

Thanks in advance for any advice...

1 Reply

  • The rule logic looks correct. Can you add a few log statements to see what's happening? I think something like this should work:

    
    log "New request for " + http_host
    if (http_host contains one of ValidDomains){
       log "Request matched class ValidDomains"
       log "substr: " + substr(http_uri, 1, '?') 
       if (substr(http_uri, 1, '?') contains one of SecurePages) {
          log "redirecting to https://" + http_host + "/" + http_uri
          redirect to "https://%h/%u"
       }
       else {
          log "Client requested non-secure page, sending to pool"
          use pool mywebfarm
       }
    }
    else {
       log "Client requested invalid host.  Redirecting to: http://www.mydomain.com/" + http_uri"
       redirect to "http://www.mydomain.com/%u"
    }

    Aaron