Forum Discussion
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.
- BeakerCirrus
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
- Chris_MillerAltostratus
Are you trying to simply rewrite the domain of the host-header on an inbound request before it gets sent to a pool member?
- m00tAltostratus
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
- m00tAltostratus
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)
- m00tAltostratus
Thank you, Beaker!! :)
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com