Forum Discussion
Chris_Corsaro_1
Nimbostratus
Mar 16, 2006uri pool redirection using single domain
Hello,
I need to redirect user connections from a single domain name with different virtual server directories. I am sorry but I'm very new to iRules, so please bear with me, I am truly a n...
Mar 16, 2006
Your iRule should work just find. You might want to make the uri lowercase before you do a comparison in case your webserver is non case sensitive.
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri contains "client1" } {
pool Client1-Pool
} elseif { $uri contains "client2" } {
pool Client2-Pool
} elseif { $uri contains "client3" } {
pool Client3-Pool
}
}You might also want to use the "starts_with" operator so that you don't catch that string somewhere else in the uri (ie. http://www.foo.com/foo.bar?client1). Also, if your naming schema wraps past 10, keep in mind that /client10 will match your first comparison. Make sure you put the client10 check before the client1.
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri starts_with "/client1" } {
pool Client1-Pool
} elseif { $uri starts_with "/client2" } {
pool Client2-Pool
} elseif { $uri starts_with "/client3" } {
pool Client3-Pool
}
}If your iRule gets very large due to a lot of mappings, you could look into using a data group to store the mappings in and then build the logic to extract the token you want to search for from the uri and use that as a search string with the "findclass" method.
Check out the wiki for all the command help and samples.
-Joe
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
