Forum Discussion
John_Merritt_45
Nimbostratus
Nov 06, 2006Need help with multi domain url rewrite
I am new to the iRule world. I have multiple domains that I need to rewrite. The first group should all rewrite to the same url. However I have another domain that I want to rewrite to a second url...
Colin_Walker_12
Nov 06, 2006Historic F5 Account
To create the same type of functionality with classes, assuming you have at least 2 domains that you want redirected to each location, you'd likely want to use two seperate classes.
You'd create one class for each destination location. I.E.:
class redirect_to_abc {
"host1.com"
"host2.net"
"host3.biz"
}
class redirect_to_xyz {
"host10.com"
"host9.us"
"host8.org"
}
Then you'd create a rule to check to see if the incoming host was in either of those classes, along with a fallback action in case it doesn't land in either bucket.
Something like:
when HTTP_REQUEST {
if { [matchclass [HTTP::host] ends_with $::redirect_to_abc ] } {
HTTP::redirect http://www.abc.com
} elseif { [matchclass [HTTP::host] ends_with $::redirect_to_xyz] } {
HTTP::redirect http://www.xyz.com
} else {
pool fallback_pool
}
}
As far as your other questions, the wildcard is only usable in a switch statement if you've specified glob style matching. Regarding forcing things to lowercase, it's kind of a habit, but probably wouldn't be necessary for the hostname, though it might be for the URI or many other things you may be comparing.
HTH,
Colin
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