Set Uri To Lower Case

Problem this snippet solves:

This iRule sets the path in an HTTP request to lower case. It does not modify the query string, if present in the request. The iRule expects the requested object and query string to be separated by a question mark.

Example:

Original request: http://www.example.com/myDirectory/Index.html?Param1=Value1&Param2=Value2

Modified request: http://www.example.com/mydirectory/index.html?Param1=Value1&Param2=Value2

Code :

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]"
   }
}

# This iRule is also described in SOL5694: BIG-IP ASM security policy elements are case sensitive on AskF5.com.

# Note: This rule can be simplified using the HTTP::path command:

when HTTP_REQUEST {
   HTTP::path [string tolower [HTTP::path]]
}

# Note: Due to a bug in v10.0 - 10.2.1, HTTP::path truncates the HTTP query string if present. The first rule above can be used as a workaround. This is described in CR142756 and is fixed in 10.2.1HF1.
Published Mar 18, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment