Forum Discussion

N_67263's avatar
N_67263
Icon for Nimbostratus rankNimbostratus
Jun 17, 2014

help with reference to an iRule creation.

Hi, I need to create an iRule which essentially redirects a https site to another https site but also if there is some URI in the original site this iRule should not take any action.

 

e.g. redirect https://abc.test.com to https://xyz.test.com. If the request is for https://abc.test.com/support then do not redirect.

 

Any help? In my case the URI could just be anything, does a "*" work in that case?

 

This is what I have with me:

 

when HTTP_REQUEST { if { [HTTP::uri] contains "/*"} {pool abc.test.com} else {HTTP::redirect "https://xyz.test.com"} }

 

Thanks, Nik.

 

3 Replies

  • This will redirect only in the case that the host is abc.test.com and the URI has no value specified (default is /):

     

    when HTTP_REQUEST { if { [[HTTP::host] eq "abc.test.com"] and [[HTTP::uri] eq "/"] } { HTTP::redirect "https://xyz.test.com" } }

     

    • Steve_M__153836's avatar
      Steve_M__153836
      Icon for Nimbostratus rankNimbostratus
      Would it be a good idea to do when HTTP_REQUEST { if { [[HTTP::host] eq "abc.test.com"] and [[HTTP::uri] ne "/support"] } { HTTP::redirect "https://xyz.test.com" } } in case someone puts some additional path after the "/" that isn't "support"?
  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    If the resources on the original domain are in flux (e.g. if files are added/removed regularly) you can create a dynamic solution that triggers the redirect only if the original request resulted in an HTTP response code 404. I can elaborate if necessary.