ltm rule command HTTP uriΒΆ

iRule(1)						BIG-IP TMSH Manual						  iRule(1)

HTTP::uri
       Returns or sets the URI part of the HTTP request.

SYNOPSIS
       HTTP::uri (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

       Note that in the HTTP_PROXY_REQUEST event, this command returns the complete proxy URI. This includes the scheme, host and
       port, and thus the result would be: http://www.example.com:8080/main/index.jsp?user=test&login=check

       Syntax

       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 

	    * 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.

       HTTP::uri -normalized

	   * Returns the URI normalized in a form for consistent comparisons.

RETURN VALUE
       Returns the URI part of the HTTP request.

VALID DURING
       ASM_REQUEST_DONE, CACHE_REQUEST, CACHE_RESPONSE, HTTP_CLASS_FAILED, HTTP_CLASS_SELECTED, HTTP_PROXY_REQUEST, HTTP_REQUEST,
       HTTP_REQUEST_DATA, HTTP_REQUEST_SEND, HTTP_PROXY_CONNECT, REWRITE_REQUEST_DONE, SERVER_CONNECTED, MR_INGRESS, MR_EGRESS,
       MR_FAILED

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.

	when HTTP_PROXY_REQUEST {
	   log local.0 "This proxy request is:[HTTP::uri]"
	}

HINTS
SEE ALSO
       See HTTP::path and HTTP::query for other ways to inspect and alter the URI.

CHANGE LOG
       @BIGIP-9.0.0 --First introduced the command.

BIG-IP							    2022-04-12							  iRule(1)