Forum Discussion

Ijaz_37879's avatar
Ijaz_37879
Icon for Nimbostratus rankNimbostratus
Jun 29, 2009

URI redirection

Hello:

 

 

Can somebody validate the following iRule?

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] equals {http://www.abc.com/123}} {HTTP::uri {https://www.123.com/xyz}

 

}

 

}

 

 

I need to redirect a HTTP request to HTTPS.

 

 

Thanks,

 

Ijaz

6 Replies

  • Hi Ijaz,

    If you want to redirect a client from http to https by sending them a 30x redirect, you can use an iRule like this:

     
     when HTTP_REQUEST { 
      
         Check if host header and URI match 
        if {[string tolower [HTTP::host]] eq "www.abc.com" && [HTTP::path] starts_with "/123"}{ 
      
            Redirect client to new host and URI 
           HTTP::redirect "https://www.123.com/xyz" 
        } 
     } 
     

    If you want to send some requests to one pool via SSL and other requests to another pool without SSL, let me know and I can provide another example.

    Aaron
  • Do you have a space in the name you're trying to use for the iRule? You can't use spaces in most LTM object names. Can you try redirect_alumno or something like that?

     

     

    Aaron
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The iRule looks correct to me, could you paste the entire log entry to show the source of the error?

     

     

    Colin