Forum Discussion
Martijn_Dekkers
Nimbostratus
Jun 15, 2006Matching wildcards in URI
Hi all, I'm new to iRules and could use some help.
I am trying to redirect to https if certain portions of the uri match - a sample uri would be http://testserv/test/folder1/folder2/id=1234 ...
hoolio
Cirrostratus
Jun 15, 2006Hi Martijn,
You can use a regular expression with matches_regex:
when HTTP_REQUEST {
if { [HTTP::uri] matches_regex "(?i)^\/test\/.*id\=1234" } {
log local0. "URI matched regex: [HTTP::uri]"
pool http_pool
} else {
log local0. "URI didn't match regex: [HTTP::uri]"
pool other_pool
}
}The regex: (?i)^\/test/\.*id\=1234
is broken down as:
(?i) - case insensitive comparison
^ - asserts that the following token is the first one in the string
\/ - literal forward slash
test - literal
\/ - literal forward slash
.* any number of non-line break characters
id - literal
\= - literal =
1234 - literal
I believe the regex libary is PCRE (Perl Compatible Regular Expression), but someone can correct me if I'm wrong.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects