Forum Discussion

AK_164512's avatar
AK_164512
Icon for Nimbostratus rankNimbostratus
May 15, 2016

rewrite iRule

I'm trying to write an iRule that will redirect users from one URI to another.

 

Users will connect via an external facing URL and then F5 needs to rewrite it to a different URL and send it to the default pool e.g

 

1)users comes as https://ddd.com/Ecf and hits F5 2) F5 needs to check if the Uri portion contains /Ecf if yes, then it changes the host part to ccc.com and the final url should be something like http://ccc.com/Ecf and sends it to the default pool/node. 3) no change in the user URL it should still remain ddd.com/Ecf

 

Any ideas ?

 

1 Reply

  • Hey,

    This rule will retain original request URI, but replace Host. There's no need for iRule to cover the rest of what you asked for. You cover the delivery to Default Pool by setting a Default Pool in VS config. You cover the delivery to plain HTTP port by setting TCP/80 port in Pool Member config.

    when HTTP_REQUEST {
    
      if { ([string tolower [HTTP::host]] eq "ddd.com") && ([HTTP::uri] starts_with "/Ecf") }{
        HTTP::header replace Host "ccc.com"
      }
    
    }
    

    Regards,