Forum Discussion
stephen1
Nimbostratus
Mar 17, 2014Detect mobile device use iRule
dear 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
Redirect the user to a mobile optimized sit...
IheartF5_45022
Nacreous
Mar 17, 2014Hi you need to use {} to enclose your regex instead of "". Also for the iRule try this;-
if { [HTTP::header User-Agent] matches_regex {(Android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|Android|iP(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino}} {
It's a mobile device
if {[HTTP::uri] eq "/?fr=mb"} {
HTTP::redirect "http://www.mydomain.com/"
} else {
HTTP::redirect "http://m.mydomain.com/"
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects