Forum Discussion
C_D_18583
Nimbostratus
Jun 27, 2006Apache mapping and F5 Irules
Here is one Apache mapping using mod_rewrite.
/cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=A http://at-consume.tsl.da.com:2200/telus-cp-portal-web/jsp/productcatalogue/personal/index.jsp?
I would like BIP IP to handle this redirect by using IRules something like:
RULE NAME : S_REDIRECT
VERSION : 1.0
DESC : Redirect
when HTTP_REQUEST {
if { [HTTP::uri] equals " /cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=A" } {
HTTP::redirect "http://at-consume.tsl.da.com:2200/telus-cp-portal-web/jsp/productcatalogue/personal/index.jsp"
}
}
Is there a more elagant way to write this Irule? For example using datagroups?
- If you are just doing a single rewrite, then data groups are overkill. This is probably as simple as it gets. If you need to have many redirects, then a data group might make a more readible iRule.
- C_D_18583
Nimbostratus
Joe - dennypayne
Employee
If all the URIS in a datagroup go to the SAME redirect, then you can use datagroups, but if all the redirects themselves are different I don't see a way to do it, you'll have to call them out individually.when HTTP_REQUEST { if { matchclass [HTTP::uri] equals $::Region1 } { HTTP::redirect "http://at-consume.tsl.da.com:2200/telus-cp-portal-web/jsp/productcatalogue/personal/index.jsp" } }
- Ahh, you learn something new every day.
class redirects { /cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=A http://redirect1.com/path1 /cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=B http://redirect2.com/path2 /cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=C http://redirect3.com/path3 /cgi-ads/jsp/viewitem.do?category=personal_services_local&Region=D http://redirect4.com/path4 }
when HTTP_REQUEST { set my_redirect [findclass [HTTP::uri] $::redirects " "] if { $my_redirect ne "" } { HTTP::redirect $my_redirect } }
- JRahm
Admin
You can use the datagroups for multiple URI and redirects:when HTTP_REQUEST { if { matchclass [string tolower [HTTP::uri]] equals $::Region1 } { HTTP::redirect [findclass [string tolower [HTTP::uri]] $::Region1 " "] } }
- JRahm
Admin
Looks like Joe beat me to it, and with an explanation to boot! - dennypayne
Employee
Excellent, thank you both for your examples! - C_D_18583
Nimbostratus
Thank you all the solutions. I tried the examples you provided and I must say it is a very clean way to handle this mapping instead of the IF statements.
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