Forum Discussion
jrosales2000_10
Nimbostratus
Dec 01, 2009Using Priorities in irules
Hi, i am trying to accomplish the following:
1) if user enters abc.com redirect to https://www.abc.com
2) if user enters www.abc.com redirect to https://www.abc.com
...
hoolio
Cirrostratus
Dec 01, 2009Hi Jodie,
Priority allows you to specify which iRules or iRule events run in which order. Priority by itself doesn't prevent any code from running though. The issue you're running into is that you cannot try to redirect or send an HTTP(S) response more than once for a single HTTP request.
You can combine the two steps in one iRule and avoid this issue:
when HTTP_REQUEST {
1) if user enters abc.com redirect to https://www.abc.com
2) if user enters www.abc.com redirect to https://www.abc.com
Check the requested host header value (set to lowercase)
switch [string tolower [HTTP::host]] {
"abc.com" -
"www.abc.com" {
Redirect client to https://www.abc.com/
HTTP::redirect "https://www.abc.com/"
}
default {
Take some default action?
}
}
}
If you want to preserve the originally requested URI in the redirect, you can check the redirect to:
HTTP::redirect "https://www.abc.com[HTTP::uri]"
Aaron
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