How to modify iRule for mobile redirect to exclude a certain user agent
Hello, I have a working iRule that detects user agents using adata group named "mobile_ua_dg", then based on the site requested it redirects the request to a URL from another data group named site_redirect_dg. Everything is working fine except now we have a google search appliance that has a user agent called "secmgr" which gets redirected to mobile because in my data group we have "sec" and the logic uses contains for the data group. How can I send "secmgr" to the full site without removing "sec" from the data group or changing the logic to "equals" rather then "contains"? Below is my iRule: when HTTP_REQUEST { log local0. [IP::client_addr] log local0. [HTTP::host] log local0.info "User-Agent = [HTTP::header User-Agent]" Use full site if user has main (non-mobile) site cookie if {[HTTP::cookie site] eq "main"}{
Do not redirect clients who have manually opted for the main site
} else {
User has not manually opted for the main site
Check if the client is a mobile
if {([class match -- [string tolower [HTTP::header "User-Agent"]] contains mobile_ua_dg]) && ([class match -- [string tolower [HTTP::host]] contains site_redirect_dg])} {
set m_redirect [class match -value -- [HTTP::host] equals site_redirect_dg ]
redirect to appropriate mobile site
if {[TCP::local_port] eq "80"} {
HTTP::redirect "http://$m_redirect[HTTP::uri]"
} else {
HTTP::redirect "https://$m_redirect[HTTP::uri]"
}
}
}
}
Thanks
Bill