My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 09, 2009 by owens.conor
MobileDesktopTraffic  
How we split mobile and desktop traffic

Introduction

This document sets out a means for serving different web pages to different device types. It describes the configuration settings for Apache running on a Redhat server because that is what we are using.

Details

For each request we set some environment variables based on matching strings against the useragent. This is done by placing a file called useragent-detection.conf in the directory /etc/htppd/conf.d. (All files in this directory are loaded by the following lines in the main httpd.conf:

#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf

The useragent-detection.conf contains:

# This file will attempt to distinguish between desktop browsers and Mobile Internet Devices.

# Unset all access environment variables
UnsetEnv IS_MOBILE_INTERNET_DEVICE
UnsetEnv IS_DESKTOP_INTERNET_DEVICE

# Set environments variable if it matches patterns in the User-Agent string.

#SetEnvIf + SetEnvIfNoCase
#Description:   Sets environment variables based on attributes of the request [without respect to case]
#Syntax:        SetEnvIf[NoCase] attribute regex [!]env-variable[=value] [[!]env-variable[=value]]

SetEnvIfNoCase User-Agent "alcatel"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "audiovox"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "au-mic"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "avantgo"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "bolt"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "blackberry"       IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "blazer"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "cldc-"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "danger"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "dopod"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "epoc"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "ericsson"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "Google Wireless Transcoder"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "htc"              IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "huawei"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "iemobile"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "ipaq"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "iphone"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "ipod"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "j2me"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "lg"               IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "midp"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "mobile"           IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "mot"              IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "moto"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "motorola"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "nec-"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "netfront"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "nitro"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "nokia"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "novarra-vision"   IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "opera mini"       IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "palm"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "palmsource"       IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "panasonic"        IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "philips"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "pocketpc"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "portalmmm"        IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "rover"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sagem"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "samsung"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sanyo"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sec"              IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "series60"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sharp"            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sie-"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "smartphone"       IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "sony"             IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "symbian"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "t-mobile"         IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "untrusted"        IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "up.browser"       IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "up.link"          IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "vodafone/"        IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "wap1."            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "wap2."            IS_MOBILE_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "windows ce"       IS_MOBILE_INTERNET_DEVICE=TRUE


SetEnvIfNoCase User-Agent "Intel Mac OS X"      IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "PPC Mac OS X"        IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "Mac_PowerPC"         IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "SunOS"               IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "Windows NT"          IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "Windows 98"          IS_DESKTOP_INTERNET_DEVICE=TRUE
SetEnvIfNoCase User-Agent "WinNT"               IS_DESKTOP_INTERNET_DEVICE=TRUE

Then in our virtual host section for the relevant domain we do the following:

# Conditions which don't test for the type of device...
# Send any m.* requests to the MIPPIN page (Explicitly looking for mobile with m. )
  RewriteCond   %{HTTP_HOST}            ^m\..*$
  RewriteRule   ^/$                     http://mippin.com/MYSITENAME    [R,L]

# Send any web.* requests to mippin web page
  RewriteCond   %{HTTP_HOST}            ^web\..*$
  RewriteRule   ^/$                     /web/index.jsp                  [R,L]

# Now test device types to see where to send it

# If its a Mobile Internet Device then go to the MIPPIN service
  RewriteCond   %{ENV:IS_MOBILE_INTERNET_DEVICE}        ^TRUE$
  RewriteRule   ^/$		           http://mippin.com/MYSITENAME    [R,L]

# If its a Desktop Internet Device then go to the web service
  RewriteCond   %{ENV:IS_DESKTOP_INTERNET_DEVICE}        ^TRUE$
  RewriteRule   ^/$                     /web/index.jsp                [R,L]

# Else go to the web service.
  RewriteRule   ^/$                     /web/index.jsp                [R,L]

The list of device useragents has to be maintained based on traffic you see hitting your site.


Sign in to add a comment
Hosted by Google Code