ltm rule command HTTP redirect
iRule(1) BIG-IP TMSH Manual iRule(1)
HTTP::redirect
Redirects an HTTP request or response to the specified URL.
SYNOPSIS
HTTP::redirect REDIRECT_URL
DESCRIPTION
Redirects an HTTP request or response to the specified URL. Note that this command sends the response to the client
immediately. Therefore, you cannot specify this command multiple times in an iRule, nor can you specify any other commands
that modify header or content after you specify this command. This command will always use a 302 response code. If you
wish to use a different one (e.g. 301), you will need to craft a response using [HTTP::respond]. If the client is a
typical web browser, it will reflect the new URL that you specify. If you wish to transparently translate the URI for your
servers (so that the client browser displays the "old" URI), you can use the [HTTP::path] or [HTTP::uri] commands; the
[HTTP::header] command can also be used to set a new Host header if needed. This command is equivalent to the BIG-IP 4.X
redirect statement.
Syntax
HTTP::redirect
* Redirects an HTTP request or response to the specified URL.
RETURN VALUE
VALID DURING
CACHE_REQUEST, CACHE_RESPONSE, HTTP_CLASS_FAILED, HTTP_CLASS_SELECTED, HTTP_REQUEST, HTTP_REQUEST_DATA, HTTP_RESPONSE,
HTTP_RESPONSE_DATA, LB_FAILED, NAME_RESOLVED
EXAMPLES
when HTTP_RESPONSE {
if { [HTTP::status] == 404} {
HTTP::redirect "http://www.example.com/newlocation.html"
}
}
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-9.0.0 --First introduced the command.
BIG-IP 2022-04-12 iRule(1)