Forum Discussion
Sean_O_Brien_65
Feb 23, 2011Nimbostratus
Looking for iRule to forward based on uri
I have an iRule here:
when HTTP_REQUEST {
if {[HTTP::uri] eq "/proposals/webpagenumber1*" } {
HTTP::redirect "http://domain2.com/Services_and_Products/sub1/sub2/P...
hooleylist
Feb 25, 2011Cirrostratus
You can use a switch statement for this as well. It's more efficient as you're not performing all three checks if a prior check was true.
when HTTP_REQUEST {
switch [HTTP::path] {
"/proposals/AccessControl.htm" {
HTTP::redirect "http://domain2.com/sub1/Construction/Proposals/AccessControl"
}
"/proposals/Davis.htm" {
HTTP::redirect "http://domain2.com/sub1/Construction/Proposals/Maintenance"
}
default {
HTTP::redirect "http://domain2.com/sub1/Construction"
}
}
}
If you have a lot more URIs to check for and they're all exact matches, you could add all of them to a string datagroup with a 'string' of the URI and a value which is the redirect URL. You can check the class wiki page for examples:
http://devcentral.f5.com/wiki/default.aspx/iRules/class
Aaron
Aaron
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