I got a request to redirect one of my Website www.foods.com to www.drinks.com. In addition this when the website www.foods.com redirects to www.drinks.com user will get a message “You will be redirected to a different site”
The “set” will set the value of the variable RedirectPage01 to what ever you put in between the quotes.
[string tolower [HTTP::host]] will covert the value of the variable HTTP::host to lower case. HTTP::host is a variable set by the F5 and it the value of the host header in the HTTP request.
([HTTP::uri] equals “/”) will check to see if the URI is just plain “/”, that is it is not “/somepage.html”.
if { ([string tolower [HTTP::host]] equals “www.foods.com”) and ([HTTP::uri] equals “/”)} will check to see that both conditions are true and if they are both true the F5 will respond to the request sending the value of the variable RedirectPage01.
So if the host name is the check for host name will fail and the F5 will continue with any other logic in your iRule. If there is no other logic, then the F5 will pass the request through to the servers behind the F5 as configured.
If the hostname is but the URI is “/somepage.html”, then the check for URI will fail and the F5 will continue with any other logic in your iRule. If there is no other logic, then the F5 will pass the request through to the servers behind the F5 as configured.
Just replace the IP addresses in the example by the new name, i.e.:
when HTTP_REQUEST {
set page "
The site has been retired.
After 5 seconds, you will automatically be redirected to our new page at "
HTTP::respond 200 content "${page}" Content-Type "text/html"
}