iRule Redirection Help
Hello,
I have a peculiar situation that I'm trying to figure out if iRules can pull off for me but I'm not sure about the approach here. For context, we have one DNS entry pointing directly to a server (we'll call this example1.com) and another DNS entry that points to an F5 VIP (we'll call this example2.com). Our client wants to have it where end users who enter https://example1.com/something get redirected to https://example2.com/something. I believe with iRules this wouldn't be possible unless we created a F5 VIP for example1.com and change the DNS entry to point to this new F5 VIP. So a new F5 https VIP was created that didn't load balance to anything but just existed so that the DNS entry for example1.com could point to it. So I'm looking for a method to be able to redirect end users who enter https://example1.com/something to https://example2.com/something. I thought this would be possible with something like this:
when HTTP_REQUEST {
if { [HTTP::host] equals "example1.com" } {
if { [HTTP::path] equals "/something" } {
HTTP::redirect "https://example2.com"
}
}
}
There's also an iRule applied to the VIP that example2.com points to for redirecting users who enter https://example2.com to https://example2.com/something, which is currently working. The idea was to have an iRule applied to the VIP of example1.com to redirect end users entering https://example1.com/something to https://example2.com and then the other iRule applied to the VIP that example2.com points to would handle the redirect to https://example2.com/something. However, this isn't working as planned and I'm not as knowledgeable with iRules to figure out alternatives.