Forum Discussion
KTrout_49248
Nimbostratus
Apr 16, 2008HTTP redirect to Pools members
How can I create an iRule that will redirect a specific URL to a pool of Web servers hosting the website?
- Kevin_Stewart
Employee
Try this:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/url1" { pool pool1 } "/url2" { pool pool2 } default { pool pool1 } } }
- KTrout_49248
Nimbostratus
Again, forgive the stupidity here. - Kevin_Stewart
Employee
This is assuming that you have more than one pool of web servers, otherwise configure the virtual server profile to point to a single defined pool on the resources tab.when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/url1" { pool web } "/url2" { pool web2 } default { pool web } } }
- winifred_corbet
Nimbostratus
Along those same lines, I need to retain the full URI coming in. So, url1/otherfile.html also needs to be directed to pool web, but keep it's full path. Would this rule above still be valid? - winifred_corbet
Nimbostratus
Also, how do I handle someone coming in as http://www.mysite.com/ with no URI, I need a URI of "/" to redirected to correct pool as well. - Kevin_Stewart
Employee
The uri won't be affected by the load balancing, so the server will get the whole thing. There's two ways to catch the base "/", using this structure, that I can think of. Perhaps one of the gurus can confirm this:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/url1*" { pool web } "/url2*" { pool web2 } "/" { pool web } default { pool web } } }
- Nicolas_Menant
Employee
if you have a lots of different uri to filter you should have a look at creating class with the findclass commands: Click here
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