Forum Discussion
ppphatak_127926
Nimbostratus
Sep 07, 2005findclass function doesnt work
I have a class called "myclass" having two members.
www.test1.com,www.yahoo.com
www.test2.com,www.msn.com
and wish to run this single rule against it.
redirect to getfiel...
Sep 09, 2005
Here are the docs for those methods:domain() - Parses and returns up to the specified number of trailing parts of a domain name from the specified expression.findclass() - The findclass() function finds the member of a class that starts with or matches the beginning of that class member. This function returns the value of that class member. This is similar to the one of class identifier, except that the member is not required to be equal; instead, the member is only required to start with the string and returns the entire member value. getfield() - The getfield() function splits a string on a character, and returns the string corresponding to the specific field. The function returns an empty string if the value of does not evaluate into a string, or if the specified value is greater than the number of fields the evaluated was split into. If the specified character or string is not found in the evaluated , then it is treated as one field.
Let's break this down
x = domain(http_host,1)
y = findclass(x, myclass)
z = getfield(y, ',', 2)
So, let's say you are passing in the following uri: http://www.test1.com.
x = domain("www.test1.com", 1)
// x will now contain "com" since you specified
// to return up to 1 trailing part of the domain name.
I don't think this is what you were going for. I believe that since you have the full domain name in the class, you don't need to be extracting the domain from the full host value.
I would try the following:
class myclass {
www.test1.com,www.yahoo.com
www.test2.com,www.msn.com
}
redirect to getfield(findclass(http_host, myclass), ',', 2)
Or, you if you want to redirect all domain level requests, you could do the following:
class myclass {
test1.com,www.yahoo.com
test2.com,www.msn.com
}
redirect to getfield(findclass(domain(http_host, 2), myclass), ',', 2)
Also, you might want to append the http_uri to the request if you want the uri portion of the redirect to match, otherwise the uri on the original request will be ignored.
-Joe
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