Forum Discussion
cquick11_115408
Nimbostratus
Mar 27, 2014A "catch all rule" for redirects
We were trying to create a rule with specific redirects, but instead of creating a rule for every domain, we would like to use a default catch. So far we have this, we had the event disable and disable all, but that didn't work correctly. I added return instead, and that is looking ok so far. I am concerned about the resource hit as everything for joe.com will hit the first rule. Is there a better way to do this?
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] ends_with "joe.com")} {
log local0. "[IP::client_addr] [HTTP::host][HTTP::uri] Disable Irule"
return
}
switch -glob [string tolower [HTTP::host]] {
"*sue.com" {
HTTP::respond 301 Location "http://www.joe.com/sue/Default.aspx"
}
default {HTTP::respond 301 Location "http://www.joe.com/joe/default.aspx"}
}
}
2 Replies
- Kevin_Stewart
Employee
Try this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "*.joe.com" { return } "*.sue.com" { HTTP::redirect "http://www.joe.com/sue/Default.aspx" } default { HTTP::redirect "http://www.joe.com/joe/Default.aspx" } } } - cquick11_115408
Nimbostratus
much cleaner, thanks for the help!
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