09-Jun-2018 11:25
Hi,
Is it possible to redirect a particular HTTP request to a particular URL based on the hostname and all other HTTP requests for that VIP to another URL using the following iRule.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.com" } { HTTP::redirect "https://yoursite1.com"; } else {HTTP::redirect "https://mysite09.com";}
}
Is it mandatory to use [string tolower ] when we are matching a [HTTP::host] Or can the iRule be written as
when HTTP_REQUEST { if { [HTTP::host] equals "site.com" } { HTTP::redirect "https://yoursite1.com"; } else {HTTP::redirect "https://mysite09.com";}
}
Thanks,
Yugandhar.
09-Jun-2018
11:54
- last edited on
05-Jun-2023
13:02
by
JimmyPackets
Yes, this is possible. The
string tolower
function isn't mandatory, but it's probably better to use it so you will catch all upper- and lowercase variations of the hostname.
I see you use semicolons in your iRule. You don't need these.