Forum Discussion

m00t's avatar
m00t
Icon for Altostratus rankAltostratus
Apr 14, 2020

iRule for domain host replacement

Hey all,

 

I've been racking my brain trying to get a domain host replacement for a wildcard domain.

 

Trying to do anything:

 

*.domain1.com to redirect to *.domain2.com with the URI. Can't seem to do the replacement of the domain/hostname.. Any suggestions? I thought it would be simple, but proving not so much.

6 Replies

  • Are you trying to simply rewrite the domain of the host-header on an inbound request before it gets sent to a pool member?

    • m00t's avatar
      m00t
      Icon for Altostratus rankAltostratus

      Yep, want it to completely redirect to the other domain.

  • Hello,

     

    Please try below iRule,

     

     

    when HTTP_REQUEST {

     

       if { [HTTP::host] equals "domain1.com"} {

     

    HTTP::redirect "https://domain2.com[HTTP::uri]"

     

    }

     }

     

     

    Also you can even try to achieve this using policy.

     

     

    Hope it works !

    Mayur

  • m00t's avatar
    m00t
    Icon for Altostratus rankAltostratus

    Mayur, Thanks for that, but that just redirects a single domain1.com to domain2.com -- I need all the wildcard virtual domains to redirect too.. for instance site1.domain1.com to site1.domain2.com -- trying to do it without individual redirects for every virtual domain (thousands)