Forum Discussion

Poonam_Dronamra's avatar
Poonam_Dronamra
Icon for Nimbostratus rankNimbostratus
Dec 06, 2006

Irule Redirect Issue

I am trying to redirect the host portion to another URL

 

 

http://2007pece.mpiweb.org redirected to

 

http://www.mpiweb.org/cms/mpiweb/pece2007/pecetemplate.aspx?id=7390

 

 

and http://20007cmme.mpiweb.org redirected to http://www.mpiweb.org/cms/mpiweb/cmme2007/cmmetemplate.aspx?id=7432

 

 

and the following iRule is applied but does not perform the redirection

 

 

when HTTP_REQUEST {

 

set host [string tolower [HTTP::host]]

 

if {[HTTP::host] contains "2007pece"} {

 

HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/pece2007/pecetemplate.aspx?id=7390"

 

} elseif {[HTTP::host] contains "2007cmme"} {

 

HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/cmme2007/cmmetemplate.aspx?id=7432"

 

}

 

}

 

 

Please could someone let me know what is wrong with the syntax.

 

 

I would really appreciate it.

 

 

Thank you very very much.

 

 

-Poo

 

 

3 Replies

  • I have also tried the following with no positive results.

     

     

     

    when HTTP_REQUEST {

     

    set host [string tolower [HTTP::host]]

     

    if {$host contains "2007pece"} {

     

    HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/pece2007/pecetemplate.aspx?id=7390"

     

    } elseif {$host contains "2007cmme"} {

     

    HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/cmme2007/cmmetemplate.aspx?id=7432"

     

    }

     

    }
  • The most obvious question first: have you applied this iRule as a resource to the virtual server you are passing traffic through?

     

     

    If you have, then next I would throw some logging in there to determine what the issue is. The code looks good to me.

     

     

    when HTTP_REQUEST {
      set host [string tolower [HTTP::host]]
      log local0. "URI: '[HTTP::uri]'"
      log local0. "Host: '[HTTP::host]', lc -- '$host'"
      if {$host contains "2007pece"} {
        log local0. "$host contains '2006pece'"
        HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/pece2007/pecetemplate.aspx?id=7390"
      } elseif {$host contains "2007cmme"} {
        log local0. "$host contains '2007cmme'"
        HTTP::redirect "http://www.mpiweb.org/cms/mpiweb/cmme2007/cmmetemplate.aspx?id=7432"
      } else {
        log local0. "$host didn't match any filtering criteria"
      }
    }

     

     

    Run a request through the Virtual with this iRule associated to it and take a look at the /var/log/ltm file. If you still can't figure out what's going on, pass the log output back here and I'll take a look.

     

     

    -Joe
  • Thank you very very much for your help.

     

     

    It works, there were some DNS issues, and another rule that was superceding my rule.