All,
I seem to be spinning my wheels here and I am not sure why. I want to do the following:
1. Detect if a user is coming from a mobile device (for simplicity, we will say only iPhone, iPad, Android, Blackberry, and Windows Mobile)
2. Redirect the user to a mobile optimized site, but:
a. If the user has already been to the mobile site, then exit from detection and allow to full site.
b. If the user is going to a specific URI on the full site, redirect to the specific site on the mobile (trying to accomplish with a Class Search
c. All others should go to mobile site if detected, else go to full site.
d. I will also need some form of tracking (a) to ensure the user does not go back to the mobile site for the duration of the session (not sure how to do this other than cookie which is not supported by ALL devices.
Below is what I have so far, but it does not seem to be working, and I do not know why???
when HTTP_REQUEST {
set uri [string trimright [HTTP::uri] “/” ]
set mobile_site “http://m.site.com”
set full_site “http://www.site.com”
if {$uri eq “/?mobile=false”} {
HTTP::redirect $full_site
event disable
} else {
set mobile_opt_uri [class search -value mobile_phone_optimized eq [string tolower $uri]]
switch -glob [string tolower [HTTP::header User-Agent]] {
“*blackberry*” -
“*wp7*” -
“*androi*” -
“*iphone*” -
“*ipad*” {
if {$mobile_opt_uri ne “” } {
HTTP::redirect $mobile_site }
HTTP::redirect $mobile_site/$mobile_opt_uri
}
}
}
if { [string tolower [HTTP::header Accept]] contains “vnd.wap.wml” } {
HTTP::redirect $mobile_site
return
}
}