Forum Discussion
Thamer_3789
Nimbostratus
Sep 23, 2012mobile device redirection
Hi All;
i want to apply this iRule to redirect the mobile devices traffic to another web site by detecting the "user agent" header...may you check it guys !!!!
when HTTP_REQUEST {
if { [string tolower [HTTP::host][HTTP::uri]] contains "www.mysite.com" } {
if { [class match [string tolower [HTTP::header User-Agent]] equals mobile_device_types ] }{
HTTP::redirect "http://m.mysite.com"}
}
}
* Where " mobile_device_types " is a data group ...
Thanks in advanced
3 Replies
- nathe
Cirrocumulus
Thamer,
From a quick glance it looks fine. My suggestion would be use "contains" rather than "equals" as to match every user-agent that way in your data group sounds like a lot of work. You could then do generic variables like "mobile" in the data group. Unless of course you want to be very specific on the user-agents. Just my two penneth..
Hope it works
N - hoolio
Cirrostratus
As Nathan said, maybe something like this:when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.mysite.com" } { if { [class match [string tolower [HTTP::header User-Agent]] contains mobile_device_types ] }{ HTTP::redirect "http://m.mysite.com" } } }
Aaron - Thamer_3789
Nimbostratus
Thanks Guys :)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
