Forum Discussion
Jason_19901
Nimbostratus
Jul 25, 2011Validate iRule
when HTTP_REQUEST {
Check if host is abc.com
if {[string tolower [HTTP::host]] eq "abc.com"}{
Rewrite the URI to /irj
HTTP::uri "/irj"
}
}
else
{
check if host is xyz.com
if {[string tolower [HTTP::host]] eq "xyz.com}{
rewrite the uri to /irq
HTTP::uri "/irq"
}
}
I have really never used more than one url. I need to append the URI. I want to know if the 'else' is correct or is it 'else if'
2 Replies
- nitass
Employee
can u try this?
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] eq "abc.com"} {
HTTP::uri "/irj"
} elseif {[string tolower [HTTP::host]] eq "xyz.com"} {
HTTP::uri "/irq"
} else {
do something
}
}
or
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"abc.com" {
HTTP::uri "/irj"
}
"xyz.com" {
HTTP::uri "/irq"
}
default {
do something
}
}
} - Colin_Walker_12Historic F5 AccountKeep in mind that your iRule as it's written will redirect all requests to a single URI. Just making sure that's what you want. ;)
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