HTTP::uri

Description

Returns or sets the URI part of the HTTP request. This command replaces the BIG-IP 4.X variable http_uri.
For the following URL:
http://www.example.com:8080/main/index.jsp?user=test&login=check
The URI is:
/main/index.jsp?user=test&login=check

Syntax

HTTP::uri
HTTP::uri -normalized
HTTP::uri <string>

HTTP::uri

  • Returns the URI given in the request. This typically does not include the protocol (http or https) or hostname, just the path and query string, starting with a slash.

HTTP::uri -normalized

  • Returns the URI given in the request after normalizing it. This typically does not include the protocol (http or https) or hostname, just the path and query string, starting with a slash. Introduced in v12.1.0, the normalization of the uri removes unnecessary directory traversals, converts from microsoft style %uxxxx form to the standard %xx hex form, normalizes bytes not allowed in a uri to their percent-encoded representation, changes unnecessary percent-encoded bytes to their normal representation

HTTP::uri <string>

  • Changes the URI passed to the server. It should always start with a slash (unless using an absolute URI). Rewriting the URI will only affect the request to the pool member. The client will not see the update unless the web application uses the requested URI to generate response headers and/or content. If you want the client to see the update to the URI in the browser’s address bar, you can send an HTTP redirect using HTTP::redirect or HTTP::respond.

Examples

when HTTP_REQUEST {
  if { [HTTP::uri] ends_with "cgi" } {
     pool cgi_pool
  } elseif { [HTTP::uri] starts_with "/abc" } {
     pool abc_servers
 }
}

# Make uri path start with /prefix if it doesn't already
when HTTP_REQUEST {
  if { not ([HTTP::uri] starts_with "/prefix") } {
    HTTP::uri /prefix[HTTP::uri]
  }
}

Note: If you want to check the file extension in a request, it would be more efficient to use ‘[HTTP::path] ends_with “.ext”’ instead of HTTP::uri, as HTTP::uri includes the query string and HTTP::path does not.

Notes

  • Beginning in version 11, the cached behavior changes so that the value of the uri is updated immediately after being set. Previously, you would need to log the value in a higher priority (read: higher number) of the current event or log the value in a later event in order to reflect the change.