Chapter 3: Condition Reference
141
slash is always present in the request URL being tested, because the URL is normalized before any
comparison is performed. Unless an .exact, .substring, or .regex modifier is used, the pattern
specified must include the leading ‘/’ character.
In the following URL example, bolding shows the components used in the comparison; ?q=test is
the included query component and #fragment is the ignored fragment identifier:
http://www.example.com/cgi-bin/query.pl?q=test#fragment
A URL such as the following is normalized so that a forward slash replaces the missing path
component: http://www.example.com becomes http://www.example.com/.
.port—Tests if the port number of the requested URL is within the specified range or an exact
match. URLs that do not explicitly specify a port number have a port number that is implied by
the URL scheme. The default port number is 80 for HTTP, so url.port=80 is true for any
HTTP-based URL that does not specify a port.
The patterns supported by the url.address= test are:
low_port_number—A port number at the low end of the range to be tested. Can be a number
between 1 and 65535.
high_port_number—A port number at the high end of the range to be tested. Can be a
number between 1 and 65535.
exact_port_number—A single port number; for example, 80. Can be a number between 1
and 65535.
Note that the numeric pattern used to test the url.port condition can contain no whitespace.
.query—Tests if the regex matches a substring of the query string component of the request URL.
If no query string is present, the test is false. As a special case, url.query_regex=!"" is true if
there is no query string.
The query string component of the request URL, if present, consists of all text from the first '?'
following the path, to the end of the URL, or up to the first occurrence of '#', whichever comes first.
Thus, any fragment identifier that might be present is excluded from the query string component.
If there is a query string component at all, then it begins with a '?' character.
.scheme—Tests if the scheme of the requested URL matches the specified schema string. The
comparison is always case-insensitive.
Discussion
The url= condition can be considered a convenient way to do testing that would require a
combination of the following conditions: url.scheme=, url.host=, url.port=, and url.path=. For
example,
url=http://example.com:8080/index.html
is equivalent to:
url.scheme=http url.host=example.com url.port=8080 url.path=/index.html
If you are testing a large number of URLs using the url= condition, consider the performance benefits
of a url definition block or a [url] section (see Chapter 6: "Definition Reference").