Forum Discussion

g3neration_3120's avatar
g3neration_3120
Icon for Nimbostratus rankNimbostratus
Jun 15, 2008

Redirecting URI's

Pretty new to iRules, my problem is that I have tried implenting an iRule on a test box. Basically it looks like this:

 

 

if { [HTTP:host] equals "test.co.il" and [HTTP::uri] starts_with "/seeme" } {

 

HTTP::redirect "http://www.test.co.il/test1/test2/seeme/index.htm" }

 

 

The redirect will only work if I type in:

 

 

test.co.il/seeme/

 

 

but not if I type in:

 

 

test.co.il/seeme

 

 

Any help would be great. Thanks.

 

2 Replies

  • Actually it works now, probably made a typo somewhere? Not sure where, but it only works if I type in

     

     

    www.test.co.il/seeme

     

     

    and not if I type in:

     

     

    test.co.il/seeme which is the desired result. Both would be nice.
  • You can change equals to ends_with so the redirect is triggered for www.test.co.il and test.co.il.

     
     if { [string tolower [HTTP:host]] ends_with "test.co.il" and [HTTP::uri] starts_with "/seeme" } { 
        HTTP::redirect "http://www.test.co.il/test1/test2/seeme/index.htm" 
     } 
     

    Aaron