Forum Discussion
Mark_Porter_979
Nimbostratus
Oct 12, 2005Percent character encoding and irules
I have an irule that looks at the request_uri to determine which pool to use:
if (http_uri matches_regex "/[Vv][Ee][Nn][Dd][Oo][Rr]_[Mm][Gg][Tt]") {
use pool lm-pmweb-2k3
}
else {
use pool lm-web-prod
}
The problem is that the 2k3 IIS devices are building a redirect to add the trailing / onto the directory name, but encoding the _ character.
If I request http://site.d.com/vendor_mgt, IIS responds with a 302, and sends me to http://site.d.com/vendor%5Fmgt/ . The problem is that by replacing the _ with a %5F, the irule doesn't match any longer, and I go to the wrong pool.
Is there a way to make the irule decode the %5F so that it will match?
2 Replies
- Colin_Walker_12Historic F5 AccountI'd suggest making a change like:
if (http_uri matches_regex "/[Vv][Ee][Nn][Dd][Oo][Rr].*[Mm][Gg][Tt]") { use pool lm-pmweb-2k3 } else { use pool lm-web-prod }
This would match vendor and mgt, regardless of what seperated them.
You could, of course, make a more strict version to only match a certain number of characters if you so chose.
-Colin - Martin_MachacekHistoric F5 AccountMark,
if you are running BIG-IP 4.6.x or newer, you can use following rule:rule match_vendor_mgt { if(tolower(decode_uri(http_uri)) == "/vendor_mgt") use pool lm-pmweb-2k3 } else { use pool lm-web-prod } }
The decode_uri function translates %XX escape following rules defined in RFC2396. The tolower function translates ASCII uppercase characters to their lowercase equivalents. The above rule should be more efficient than regex matching.
BIG-IP versions older than 4.6 do not support the tolower function.
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