Forum Discussion
WAP and mobile irule question
The goal is if a mobile phone with it's user_agent included in a Data Class to direct it to one site and if it isn't in the Data Class then redirect somewhere else.
I think my logic might be off. Can anyone take a look?
when HTTP_REQUEST {
set wap "https://onesite.com "
set normal "http://www.google.com"
if {[class match [string tolower [HTTP::header User-Agent]] contains user_agent_tokens_class]}{
HTTP::redirect $wap
log local0. "WAP"
} elseif { not ([class match [string tolower [HTTP::header User-Agent]] contains user_agent_tokens_class])}{
Redirect to the normal
HTTP::redirect $normal
log local0. "No WAP"
} else {
}
}
I am using a Nokia simulator to test and then using just a normal browser to test non-list WAP phones.
Thanks for any assistance.
7 Replies
- Mohamed_Lrhazi
Altocumulus
The logic looks off... - What_Lies_Bene1
Cirrostratus
This should achieve the desired result;when HTTP_REQUEST { set wap "https://onesite.com " set normal "http://www.google.com" if { [class match [string tolower [HTTP::header User-Agent]] contains user_agent_tokens_class] } { HTTP::redirect $wap log local0. "WAP" } else { Redirect to the normal HTTP::redirect $normal log local0. "No WAP" } }
- pmaubo2_55685
Nimbostratus
The problem I seem to run into is it sends it to the wap redirect no matter if it's one of the codes in my data class or not and even if I just use a browser so it never seems to get to the 2nd redirect via the else. - What_Lies_Bene1
Cirrostratus
If that's the case, even with my suggested modifications, I'd suggest you change the log statements to also log the User-Agent so you have an idea what's being presented.
Is everything in your data group lower case? It needs to be!
- pmaubo2_55685
Nimbostratus
Below is the output. The 1st one shows the redirect via just a browser, the one below shows correctly that it saw the nokia keyword in the data class. For some reason I must be missing some type of end statement or event disable, tried that but no dic. - What_Lies_Bene1
Cirrostratus
OK and that's using my iRule? - nitass
Employee
i think you have to add additional condition in if clause, such as host header or uri, to prevent redirection loop.when HTTP_REQUEST { if { [HTTP::host] equals "onesite.com" } { if { not [class match -- [string tolower [HTTP::header User-Agent]] contains user_agent_tokens_class] }{ HTTP::redirect "http://www.google.com" } } else { if { [class match -- [string tolower [HTTP::header User-Agent]] contains user_agent_tokens_class] }{ HTTP::redirect "https://onesite.com" } } }
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