Forum Discussion
AlexDeMarco
Nimbostratus
Oct 07, 2013How to append to a match_class
I have this code:
if { ([class match $req_uri starts_with PROD_uri_to_redirecttossl]) } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
but want something like this:
if ...
Kevin_Stewart
Employee
Oct 08, 2013Okay, this may seem a little odd, but I've gotten to work as follows:
Data group:
/about/
/help/
iRule:
when HTTP_REQUEST {
if { [string first "/" [HTTP::uri] 1] eq -1 } {
URI doesn't have a second "/" so just return URI
set mod_uri [HTTP::uri]
} else {
return the first level URI minus trailing "/"
set mod_uri [string range [HTTP::uri] 0 [string first "/" [HTTP::uri] 1]]
}
if { ( [class match "${mod_uri}/" equals my-dg] ) or ( [class match $mod_uri starts_with my-dg] ) } {
do something here
log local0. "match"
}
}
Essentially, I take the requested URI (ex. "/about/me"), strip it down to its first level path minus the trailing slash ("/about"), then compare it two times against the data group:
- Does the data group entry "/about/" equal the modified URI + trailing slash?
- Does the data group entry "/about/" start with the modified URI?
It will match "/about", "/about/", and "/about/me", but not "/aboutme".
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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