Forum Discussion
iRule question
I have a question. I made this iRule with the help of another topic but I wanted to expand on it but not sure what to do about that.
The current iRule makes it so the first batch of websites doesn't redirect to https but i also want it to make everything that starts_with URI to not be included into the redirect either is this possible?
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host][HTTP::uri]] {
"www.abc.com/xyz/def"
- "www.abc.com/xyz"
- "www.abc1.com/xyz/def"
- "www.abc2.com/xyz/def"
- "www.abc3.com/xyz/def"
- "www.abc4.com/xyz/def"
- "www.abc5.com/xyz/def"
- "www.abc6.com/xyz/def"
- "www.abc7.com/xyz/def"
- "www.abc8.com/xyz/def"
{
return
}
default {
HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]"
}
}
}
1 Reply
- Kevin_Stewart
Employee
A few things:
-
The switch inclusion (-) operator should be at the end of the case, not the beginning.
-
The -glob operator is effectively a wildcard match that could emulate a starts_with condition using an appropriately placed "*".
Example:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host][HTTP::uri]] { "www.abc.com/xyz/def*" - "www.abc.com/xyz*" - "www.abc1.com/xyz/def*" - "www.abc2.com/xyz/def*" - "www.abc3.com/xyz/def*" - "www.abc4.com/xyz/def*" - "www.abc5.com/xyz/def*" - "www.abc6.com/xyz/def*" - "www.abc7.com/xyz/def*" - "www.abc8.com/xyz/def*" { return } default { HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]" } } } -
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
