cancel
Showing results for 
Search instead for 
Did you mean: 

iRule for domain host replacement

m00t
Altostratus
Altostratus

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 6

Chris_Miller
Altostratus
Altostratus

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

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
Altostratus
Altostratus

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)

Beaker
Cirrus
Cirrus

I have use this iRule in the past to get accomplish something similar

 

when HTTP_REQUEST {

HTTP::host [string map {".old-domain.com" ".new-domain.com"} [HTTP::host]]

HTTP::respond 307 Location https://[HTTP::host][HTTP::uri]

}

 

It should do a wild card replacement like you want, or at least similar functionality

m00t
Altostratus
Altostratus

Thank you, Beaker!! 🙂