Forum Discussion
Joe_Pipitone
Nimbostratus
Jun 05, 2009Redirect - adding elseif
I want to add multiple redirect statements to a single iRule, when a match is found, redirect, else, keep going until i find a match. Can anyone tell me what i am missing here?
when HT...
Colin_Walker_12
Jun 05, 2009Historic F5 Account
For both you'd just use the glob matching, like you already are, and add an asterisk, like so:
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob $h {
"*domain1.com" {
HTTP::redirect "http://domain2.com"
}
"*domain3.org" {
HTTP::redirect "http://domain4.org"
}
}
}
This would, of course, match anything before the domain, including all cnames. If you wanted to be more specific you could just add more match cases:
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob $h {
"www.domain1.com" -
"domain1.com" {
HTTP::redirect "http://domain2.com"
}
"www.domain3.org" -
"domain3.org" {
HTTP::redirect "http://domain4.org"
}
}
}
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
