ltm rule command HTTP pathΒΆ

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



HTTP::path
       Returns or sets the path part of the HTTP request.

SYNOPSIS
       HTTP::path (PATH_VALUE)?

DESCRIPTION
       Returns or sets the path part of the HTTP request. The path is defined
       as the path and filename in a request. It does not include the query
       string.	For the following URL:
       http://www.example.com:8080/main/index.jsp?user=test&login=check

       The path is: /main/index.jsp

       Note that only ? is used as the separator for the query string.	So,
       for the following URL:
       http://www.example.com:8080/main/index.jsp;session_id=abcdefgh?user=test&login=check

       The path is: /main/index.jsp;session_id=abcdefgh

       Syntax

       HTTP::path

	    * Returns the path part of the HTTP request.

       HTTP::path 

	   *  Changes the path part of the HTTP request. Rewriting the path will only
	      affect the request to the pool member. The client will not see the update
	      unless the web application uses the requested path to generate response
	      headers and/or content. If you want the client to see the update to the
	      path in the browser's address bar, you can send an HTTP redirect using
	      HTTP::redirect or HTTP::respond.

	  Note: AskF5 SOL9952 describes a defect in path parsing when the request
	  includes an absolute URI in the Resource-URI field.

       HTTP::path -normalized
	   *  Returns the path normalized in a form for consistent
       comparisons.

RETURN VALUE
       Returns the path part of the HTTP request.

VALID DURING
       HTTP_REQUEST, HTTP_REQUEST_DATA, REWRITE_REQUEST_DONE, SERVER_CONNECTED

EXAMPLES
	Webmail redirect example: https://webmail.company.com is redirected to
	https://webmail.company.com/exchange. Redirected traffic then passes to
	the webmail pool.

	when HTTP_REQUEST {
	  if { [HTTP::path] equals "/" } {
	    HTTP::redirect "/exchange/"
	    #log local0. "redirect"
	  } else {
	    pool pool_webmail
	    #log local0. "using pool "
	  }
	}

	To set the path to lowercase, you can use the following example.

	when HTTP_REQUEST {
	  log local0. "\[HTTP::path\] original: [HTTP::path]"
	  HTTP::path [string tolower [HTTP::path]]
	}

	Note: Due to a bug in v10.0 - 10.2.0, HTTP::path truncates the HTTP
	query string if present. The following rule can be used as a
	workaround. This is described in CR142756.

	when HTTP_REQUEST {

	   # Check if there is a query string
	if {[HTTP::query] eq ""}{

	      # No query string, so set the entire URI to lower case
	      HTTP::uri [string tolower [HTTP::uri]]

	   } else {

	      # Set the path to lower case and append the string to it
	      HTTP::uri "[string tolower [HTTP::path]]?[HTTP::query]"
	   }
	}

	You can use the BIG-IP as a primitive webserver. This uses a variable
	called $error_condition to decide to send an error page to the client,
	and a global class called $::logo_png_class. More information can be
	found on creating that class at:
	   http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=
	5&postid=9523

	when HTTP_REQUEST {
	  if { $error_condition==1 } {
	    # error condition was true, so respond back to client with html or image(s)
	    switch [string tolower [HTTP::path]] {
	      /image.png {
		HTTP::respond 200 content [b64decode [lindex $::logo_png_class]] "Content-Type" "image/png"}
	      default {
		HTTP::respond 200 content "ErrorError!"}
	    }
	  }
	}

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

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



BIG-IP				  2017-01-31			      iRule(1)