Forum Discussion
Tom_Thunem_9204
Nimbostratus
Jul 24, 2013large number of redirects
our application group has 142 redirects they want added to into an iRule. i was wondering what the most effiecient method might be. i am currently using this syntax for many of our redirects and hestiate to build a piece of logic that contains 142 different redirects... is this still the best option?
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/something*" {
HTTP::redirect "http://our-domain.com/some/URI/values"}
"/something-else*" {
HTTP::redirect http://our-domain.com/some/other/URI/values }
"/and-so-on*" {
HTTP::redirect ""}
and so on...
5 Replies
- Michael_Yates
Nimbostratus
Hi Tom,
I think that you are on the right track with the Switch Command. Unless you wanted to make a more generic iRule that uses a Datagroup to store the URI and Redirect Locations to make it simpler to manage (then you would just manage the Datagroup instead of a large iRule). - Tom_Thunem_9204
Nimbostratus
Michael,
I have yet to use a datagroup. Can you show me an example of the irule and the datagroup i would use to solve my problem? I wasn't able to apply the example i found on askf5 to my particular problem.
Thanks - Kevin_Stewart
Employee
If I may add, you have to consider whether you want to manage 142 patterns via a table structure or within procedural code. My money is on the data group option. - Tom_Thunem_9204
Nimbostratus
Can anyone show me how i might apply my problem to a datagroup? i have yet to use one, so i am unclear. I wasn't able to apply the example i found on askf5 to my particluar problem.
thanks - Kevin_Stewart
Employee
Sure.
Step 1: create a data group (LTM GUI: iRule | Data Group List | Create). Enter a name (example "my_test_dg"), select "String" type, and start entering strings and values. Example:
"/something-else" := "http://our-domain.com/some/other/URI/values"
"/something" := "http://our-domain.com/some/URI/values"
"/and-so-on" := "http://our-domain.com/and/so/on"
** I would order these from most to least specific if the URIs start with the same string values.
Step 2: Create the iRule:when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with my_test_dg] } { HTTP::redirect [class match -value [string tolower [HTTP::uri]] starts_with my_test_dg] } }
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