There is one issue that remains. There is a potion above this irule that detects a mobile phone and if it finds it in our Data Class it will use anothere Data Class for keywords and then redirect to our mobile site, so it will recieve optimized pages.
The same issues seems to plague us, if someone puts in extra characters it fails.
Following the logic you provided fixed the pc version but for some reason it does not work on the mobile issue.
Below is what I use.
when HTTP_REQUEST {
Set variables to be used later
set ckname "mobile"
set ckvalue "mobileoptfalse"
set cookie [format "%s=%s; path=/; domain=%s" $ckname $ckvalue ".someplace.com"]
if { [HTTP::query] contains "skipmobiledetect=true"}{
HTTP::respond 302 Location "https://www.someplace.com" "Set-Cookie" $cookie
}
unset ckname
unset ckvalue
unset cookie
The above statement are so if the user clicks on to the full url site it will capture cookie and not send them back to the mobile site.
set mobile_opt_uri [class match -value [string tolower [HTTP::uri]] starts_with mobile_phone_optimized_uri]
set my_uri [string trimright [HTTP::uri] "/" ]
set mobile_site "https://m.somemobileplace.com"
set mobile_uri [class search -value mobile_phone_optimized_uri eq [string tolower $my_uri]]
set query [class search -value mobile_phone_optimized_uri eq [string tolower $my_uri]]?[HTTP::query]
Check for the existence of the cookie from the mobile site and that you are not attempting to go to a page that has been optimized for mobile OR that your URI is not empty
if {([HTTP::cookie exists mobile]) and not ([class match [string tolower [HTTP::uri]] contains mobile_phone_optimized_uri])}{
} elseif { not ([HTTP::uri] == "/") and not ([class match [string tolower [HTTP::uri]] contains mobile_phone_optimized_uri])}{
} else {
Check the User Agent string for a supported Browser in the class "Mobile_Device_Provider"
if {[class match [string tolower [HTTP::header User-Agent]] contains mobile_device_providers]}{
Check the URI for a mobile optimized URI as defined in the class "mobile_phone_optimized_uri"
if {[class match [string tolower [HTTP::uri]] contains mobile_phone_optimized_uri]} {
Redirect to the appropriate site
HTTP::redirect $mobile_site$my_uri
} else {
Redirect to the mobile root
HTTP::redirect $mobile_site
}
}
event disable
}
Below is there redirect for just pc computers using a uri keyword. And even if it has extra characters it will go to the supplied using the contains.
This works fine.
See full thread