Forum Discussion
switch wildcards
Hello
I have an iRule that makes two redirections depending on User Agent.
It's something like this:
switch -glob [string tolower [HTTP::header User-Agent]] {
"*android*" -
"*windows phone*" -
"*iphone*" -
"*blackberry*" -
"*bb10*" -
"*symbianos*" -
"*webos*" -
"*windows ce*" -
"*windows phone os 7*" {
HTTP::redirect https://www.mysite.com/mobile
}
default {
HTTP::redirect "https://www.mysite.com/default"
}
}
I want to split Android on two cases:
- Smartphone: Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03O) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
- Tablet:
So, for Android smartphones, User-Agent contains both "Android" and "Mobile"
I know it can be done with an if or switch inside the previous switch. But can it be done with a single check?
Would this switch statement work? -> "*android*mobile*"
If not, I suppose I should make it with a regular expression. shouldn't I? How would it look like?
Thanks
2 Replies
- What_Lies_Bene1
Cirrostratus
Hey Manuel. Yes that would work. - What_Lies_Bene1
Cirrostratus
Note, a regular expression will only work if you use the –regexp option with switch.
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