Forum Discussion

Venkat_96085's avatar
Venkat_96085
Icon for Nimbostratus rankNimbostratus
May 08, 2009

Redirect Rule...

Hi,

 

 

I want to write an iRule for redirection but I am unable to do so. I want to read whole URL for example http://www.xyz.com and then redirect it to http://www.abc.com/index.html.

 

 

 

PLease help!!!

 

 

Regards,

 

Puneet Khanna

 

3 Replies

  • Hi Puneet,

    This should do the trick:

      
     when HTTP_REQUEST {  
        if { HTTP::host equals "www.xyz.com" } {  
          HTTP::redirect "http://www.abc.com/index.html"  
       }  
     }  
     

    Denny

    EDITED to use correct command
  • Thanks Denny...

     

     

    I tried to write given below rule..Will this work???

     

     

    when HTTP_REQUEST {

     

    switch [string tolower [HTTP::uri]] {

     

    "http://www1.qpb.com" {HTTP::redirect "http://www1.qpb.com/ecom/pages/nm/nmhomepage.jsp"}

     

    "http://www1.qpb.com/doc" {HTTP::redirect "http://www1.qpb.com/ecom/pages/nm/nmhomepage.jsp"}}

     

    }

     

     

    Puneet
  • Hi Denny,

     

     

    Would you be able to tell how the irule will look when both the host and URI is changing. Sorry i am a newbie and have not worked in coding.

     

     

    Thanks,