Forum Discussion

Robb_Holzer_770's avatar
Robb_Holzer_770
Icon for Nimbostratus rankNimbostratus
Aug 09, 2006

IRule Redirect Question

I am trying to setup an iRule for 9x that simply reads an HTTP header and then redirects to a new URL....

 

 

My rule currently is follows but is not working, suggestions on what I might try?

 

 

when HTTP_REQUEST {

 

 

if { [HTTP::host] eq "http://www.tq3navigant.com/northcentral"} {

 

 

HTTP::redirect "http://www.navigant.com/About/Locations/LocationsDetail.aspx?Region=NC&Hemi=West[HTTP::uri]" }

 

 

}

 

 

Thanks!

2 Replies

  • You can add a logging statement to the rule to find out what host you're making the comparison against:

    
    when HTTP_REQUEST {
    if { [HTTP::host] eq "http://www.tq3navigant.com/northcentral"} {
       log local0.info "Host: [HTTP::host]"
       HTTP::redirect "http://www.navigant.com/About/Locations/LocationsDetail.aspx?Region=NC&Hemi=West[HTTP::uri]" }
    }

    The output will be logged to /var/log/ltm.

    I think you'll find the Host header doesn't include the protocol or the URI. Here is the format:

    http://myhost.com/myUri/

    where http is the protocol, myhost.com is the host and /myUri/ is the URI.

    So you would want to match against "www.tq3navigant.com"

    Aaron

    [with edits for typing faster than I was thinking...]
  • hoolio's answer is technically accurate--and you may already have put his advice to good, functional use--but for the sake of being thorough, and because I need all the practice I can get, I believe this is the way you would want that iRule of yours to be written:

    when HTTP_REQUEST { 
    if { "[HTTP::host][HTTP::uri]" eq "www.tq3navigant.com/northcentral"} {
      HTTP::redirect "http://www.navigant.com/About/Locations/LocationsDetail.aspx?Region=NC&Hemi=West[HTTP::uri]"
      }
    }