Apache Mobile Filter is the easiest way to detect mobile devices.
AMF is a suite of tools that allow access to a Device Repository (such as WURFL, DetectRight, 51Degrees or others) directly from Apache: now you can detect devices no matter what language your website uses.
3. Every year more then 300 new devices
Device Fragmentation Problem
ApacheMobile Filter
4. Each mobile device has many capabilities
screensize ?
imagetype ?
wifi ?
xhtml ?
screen resolution ?
navigation type ?
streaming type ?video streaming type ?
ajax ?
gif animated ?
j2me ?os ?
gif animated ?
ApacheMobile Filter
5. The Goal
• Help people to detect easily any type of device
• have one solution for any platform (Unix, linux, OS X, Windows)
• give a simple solution for any programming language (PHP,
Python, JSP, Ruby, Perl etc....)
• Manage Images easily
• High performane
ApacheMobile Filter
7. What is the Apache Mobile Filter Project ?
“Idel Fuschini has created Apache Mobile Filter
that allows you to access WURFL from any
programming language, not just Java and php that
is traditionally used for dynamic mobile web sites.
The module detects the mobile device and passes
the WURFL capabilities on to the other web
application as environment variables. It can also be
used to resize images on the fly to adapt to the
screen size of the mobile device.”
from http://mobilephonedevelopment.com/archives/854
ApacheMobile Filter
8. Why Apache ?
for more 235,000,000 reasons
*from http://news.netcraft.com
Market Share for Top Servers Across All Domains August 1995 - July 2011
ApacheMobile Filter
9. Some info where download the software and doc
Official Site:
http://www.idelfuschini.it/apache-mobile-filter-v2x.html
Demo Site for mobile:
http://www.apachemobile.org
Demo Site for PC:
http://www.apachemobile.org
Support: support@idelfuschini.it
Apache Mobile Filter ticket system: http://amfticket.idelfuschini.it
Download Site:
http://sourceforge.net/projects/mobilefilter/
or
http://search.cpan.org/~ifuschini/
ApacheMobile Filter
10. The "Apache Mobile Filter" is one of the modules of
"Apache Module Registry" portal.
http://modules.apache.org/search.php?id=1787
modules.apache.org
ApacheMobile Filter
15. Success History
Repair Shop Websites:
The Leader in Internet Design
for the Automotive Repair Industry
“......Knowing how many phones are
available for people to search and surf
the web, we wanted to find a solution
that would automatically optimize our
sites no matter what mobile device was
being used. We found the ultimate
solution in the Apache Mobile
Filter. .......”
19. People says......
Silvian Leuthold:
“After many years in mobile industry I can say that AMF is simply the
most straightforward approach I've seen for solving common mobile
internet challenges like device recognition, media delivery and mobile
web design. Thanks a lot to Idel who was always available for
support and consulting when needed. Great Job!. October 21, 2011”
Scott Pakin:
Given the mess the mobile Web is in, with devices ignoring handheld-
targeting stylesheets, lying about their screen resolution, and otherwise
impeding the development of portable Web sites, Apache Mobile Filter
really helps tame the complexity of delivering content that's suitably
formatted for the target device. November 02, 2011
ApacheMobile Filter
20. People says......
Sergio David Acosta:
“Gracias a Idel y a su grandioso producto, el Apache Mobile Filter,
que nos permitió desarrollar los portales móviles de Casa Editorial El
Tiempo. February 15, 2010”
Kumaraswamy Nandipati:
“I did a lot R&D for image rendering on the fly for one of my mobile
website and finally it was ended up with Apache-mobile Filter. It
was nice tool and easy to adopt. I simply Love it. I appreciate idle
effort for this tool. Thanks for providing such a nice tool Idle Fu. -
Kumaraswamy.N Project Lead, ecomZera LLC.” January 16, 2010
Massimiliano Martinelli:
Very useful project, "mobilize" a portal in a very easy and fast way! The
AMF provides an all-in-one suite in order to manage contents for
mobiles in the best way!
Project Lead, Devoteam July, 2010
ApacheMobile Filter
21. AMF Architecture
Apache Mobile Filter
Suite
Device Repository
Apache Standard Environment
Apache Mobile Environment (Device Capability)
WebApplication
(php,python, ruby, jsp, perl, asp etc. etc.)
Apache Webserver
mod_perl 2.0.X
Apache Web Server (http://apache.org)
mod_perl2 (http://perl.apache.org)
WURFL (http://wurfl.sourceforge.net)
ApacheMobile Filter
22. Installation requirement
• perl v5.8.8 or more (http://www.perl.org)
• apache webserver 2.x or more (http://httpd.apache.org)
• mod_perl 2.0.4 or more (http://perl.apache.org)
• memcached 1.4.4 or more (http://memcached.org)
mkdir foo
cd foo
wget http://downloads.sourceforge.net/project/mobilefilter/ApacheMobileFilter/x.xx/Apache2-WURFLFilter-x.xx.tar.gz?use_mirror=dfn
tar -xzvf Apache2-WURFLFilter-x.xx.tar.gz
cd Apache2-WURFLFilter-x.xx/
perl Makefile.PL
make install
aptitude install libapache2-mod-perl2 libgd-gd2-perl libgd-tools
a2enmod perl
cpan Apache2::AMFWURFLFilter Apache2::Filter Apache2::RequestRec Apache2::RequestUtil Apache2::Connection Apache2::SubRequest
Apache2::Log CGI::Cookie APR::Table CGI::Cookie LWP::Simple Image::Resize Image::Scale IO::Uncompress::Unzip Cache::FileBackend
Cache::Memcached
Download Apache Mobile Filter and follow this steps:
ApacheMobile Filter
24. Admin Tool
Apache Mobile Filter Suite
Device Detection
Mobile Switcher
Image Rendering Engine
Carrier Detection
Mobile Caching System
ApacheMobile Filter
Mobile Trace
WebService
25. AMF<DeviceRepsitory>Filter
(Device Detection Module)
AMFImage
Rendering
Apache Web Server
AMF environment
PHP
WebApp
JSP
WebApp
(mod_jk)
RUBY/Python
WebApp
Mobile
Site
Version
Classic
Site
Version
Transcoder
Site
Version
HttpRedirect(301)
HttpRedirect(301)
HttpRedirect(301)
htdocs
Mobile Web Server Architecure
AMFSwitcher
AMFCarrierDetection
AMFMobileCaching
ApacheMobile Filter
AMFWebService
Third-party
applications
26. Advanced Cache System
• Two architecture of caching:
• The Apache Mobile Filter when it has identified a mobile device, stores the
capabilities in a persistent cache (filesystem)
• The Apache Mobile Filter when it has identified a mobile device, stores the
capabilities using memcached (http://memcached.org). Ideal solutions in
cluster architectures.
ApacheMobile Filter
28. Device Detection overview
AMF suite from 3.40a version supports several device repositories, each Device Repository has a
dedicated module
• AMFLiteDetectionFilter: is suggested to use for solution that not need exaclty the type of device, but
only if the device is amobile or not. Is nor require a Device Repository
• AMF51DegreesFilter*: this module use 51Degrees (http://51degrees.mobi) as device Repository
• AMFDetectRightFilter*: this module use DetectRight (http://www.detectright.com) as device Repository
• AMFWURFLFilter*: this module use DetectRight (http://www.scentiamobile.com) as device Repository
*this module has advanced cache system on filesystem or using memcached
ApacheMobile Filter
30. Configuration
WurflFilter
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlTransHandler +Apache2::AMFLiteDetectionFilter
Remember:
This module is suggested to use only to use with AMFSwitch module, is not so precise how to use a Device Repository
At startuo the module verify on apachemobilefilter.org if there are new parameter to get, ig you want to disable this
option you can set:
PerlSetEnv AMFDownloadParamURL on true
In production is suggested to set the AMFProductionMode on true:
PerlSetEnv AMFProductionMode on true
ApacheMobile Filter
Device Detection
32. Configuration
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv CacheDirectoryStore /tmp
PerlSetEnv CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all
PerlTransHandler +Apache2::AMF<DeviceRepository>Filter
Remember:
before you start you must have the device repository file
if you want to update the device repositoryl file each time you stop and start the Apache, you must specify with this
parameter:
PerlSetEnv <device repository>NetDownload true
PerlSetEnv Download<device repoisory>URL http://<url>/<device repository>.zip
In production is suggested to set the AMFProductionMode on true:
PerlSetEnv AMFProductionMode on true
ApacheMobile Filter
Device Detection
33. Configuration
WurflFilter
If you need to add more capabilities or useragents that are not includes into the DeviceRepository add this papameter:
PerlSetEnv PersonalWurflFileName mydevicerepository.xml
The path is the AMF_Home. An example for your device repository file:
<wurfl_patch>
<devices>
<device user_agent="mickey mouse" fall_back="root" id="generic">
<group id="fb">
<capability name="mynewcapability" value="false"/>
</group>
</device>
<device id="apple_iphone_ver4_3">
<group id="fb">
<capability name="mynewcapability" value="true"/>
</group>
</device>
</devices>
</wurfl_patch>
ApacheMobile Filter
Device Detection
34. AMF with Memcached
the advantage to use AMFWURFLFilterMemcached
This picture and the text are from http://memcached.org and can explain the advantage of this
architecture:
“memcached allows you to take memory from parts of your system where
you have more than you need and make it accessible to areas where you
have less than you need.
memcached also allows you to make better use of your memory. If you
consider the diagram to the right, you can see two deployment scenarios:
! 1.! Each node is completely independent (top).
! 2.! Each node can make use of memory from other nodes (bottom).
The first scenario illustrates the classic deployment strategy, however
you'll find that it's both wasteful in the sense that the total cache size is a
fraction of the actual capacity of your web farm, but also in the amount of
effort required to keep the cache consistent across all of those nodes.
With memcached, you can see that all of the servers are looking into
the same virtual pool of memory. This means that a given item is
always stored and always retrieved from the same location in your
entire web cluster.
Also, as the demand for your application grows to the point where you
need to have more servers, it generally also grows in terms of the data
that must be regularly accessed. A deployment strategy where these two
aspects of your system scale together just makes sense.
The illustration to the right only shows two web servers for simplicity, but
the property remains the same as the number increases. If you had fifty
web servers, you'd still have a usable cache size of 64MB in the first
example, but in the second, you'd have 3.2GB of usable cache.
Of course, you aren't required to use your web server's memory for
cache. Many memcached users have dedicated machines that are built to
only be memcached servers.”*
*from http://memcached.org/about
ApacheMobile Filter
Device Detection
35. Apache WebServer
Apache Mobile Filter
Memcached cluster architecture
Memcached*
*http://memcached.org/
Apache Mobile Filter
Apache WebServer
Apache Mobile Filter
Apache WebServer
Apache Mobile Filter
ApacheMobile Filter
Device Detection
37. Configuration
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv ServerMemCached 10.0.0.15:11211,10.0.0.16:11211,/var/sock/memcahed
PerlSetEnv CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all
PerlTransHandler +Apache2::AMF<DeviceRepository>FilterMemcached
Remember:
before you start you must have the device repository file
if you want to update the device repository file each time you stop and start the Apache, you must specify with this
parameter:
PerlSetEnv <device repository>NetDownload true
PerlSetEnv Download<device repoisory>URL http://<url>/<device repository>.zip
If you want to detect the not mobile browser you must need to load the web_browser_patch.xml so set this parameter
to true:
PerlSetEnv LoadWebPatch true
If you want to download directly from internet (it’s very slow):
PerlSetEnv PatchWurflNetDownload true
PerlSetEnv PatchWurflUrl http://wurfl.sourceforge.net/web_browsers_patch.xml
In production is suggested to set the AMFProductionMode on true:
PerlSetEnv AMFProductionMode true
Device DetectionApacheMobile Filter
39. Mobile Caching System (beta version)
(for cluster architecture using memcached)
AMFMobileCachingMemcached
memcached
server
AMFMobileCachingMemcached cache the different layout, of the same URL, for each type of
devices that have done the requests.
The timeout caching is configurable.
Mobile Cache System
ApacheMobile Filter
40. Configuration
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome /server_root/MobileFilter
PerlSetEnv ServerMemCached 10.0.0.15:11211,10.0.0.16:11211,/var/sock/memcahed
CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all
PerlTransHandler +Apache2::AMFWURFLFilterMemcached
<Directory /portal/*>
SetHandler modperl
PerlOutputFilterHandler Apache2::AMFMobileCacheMemcached
Allow from all
</Directory>
ApacheMobile Filter
Mobile Cache System
43. Configuration
The AMFImageRendering is working only if is active the WURFLFilter.
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome /server_root/MobileFilter
PerlSetEnv ResizeImageDirectory /tmp/cached
PerlModule Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFWURFLFilter
<Location /mobile/*>
SetHandler modperl
PerlOutputFilterHandler Apache2::AMFImageRendering
</Location>
This is indicate to the filter were
are stored the high definition
images
This indicate to the filter where put
the transformated images (cache
directory) this directory must be
writeable
/mobile /transform
(cache directory)
Browser Image Request
ImageRenderFilter
Response
or AMFWURFLFilterMemcached
ApacheMobile Filter
Image Render Engine
44. Image Render Filter
HTML Syntax
<img src=”/mobile/image.png”>
<img src=”/mobile/image.png?dim=50”>
<img src=”/mobile/image.png?width=80”>
The width of the image is 80px
The image is scaled to the 50% of the width mobile device
The image is scaled to the size of the mobile device
ApacheMobile Filter
Image Render Engine
For change the name of parameter “width” and “dim” in httpd.conf must be setted:
PerlSetEnv ImageParamWidth <new name of param>
PerlSetEnv ImageParamPerc <new name of param>
By default the images that have a width less than device screen size are not resized, if you want to force it:
PerlSetEnv ResizeSmallImage true
48. You can use the filter to redirect to other part if it came from:
web browser
mobile browser
transcoder
Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv FullBrowserUrl http://www.fullbrowsersite.com
PerlSetEnv MobileVersionUrl http://www.mobilesite.com
PerlSetEnv RedirectTranscoderUrl http://www.transcodersite.com**
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlModule Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
Configure AMFSwitcher
1) http://m.site.com
2) http://www.site.com
3) http://www.transcoder.com
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
**if the parameter “RedirectTranscoder” is omitted the transcoders are considered as mobile devices.
ApacheMobile Filter Mobile Switcher
49. You can use the filter to redirect to other part if it came from:
web browser
mobile browser
transcoder
Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv FullBrowserUrl /web_dedicated_site
PerlSetEnv MobileVersion /mobile_dedicated_site
PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
AMFSwitcher (redirect in the same site)
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
If for example you change the FullBrowserUrl parameter with value “/”, you defined that FullBrowser devices can
access to all site.
ApacheMobile Filter Mobile Switcher
50. Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv FullBrowserUrl /web
PerlSetEnv MobileVersion /mobile
PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site
PerlSetEnv WildCardRedirect true
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
AMFSwitcher (redirect in the same site)
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
ApacheMobile Filter Mobile Switcher
http://www.site.org/mobile/hello.html?go=12 http://www.site.org/web/hello.html?go=12
Redirect for pc browser
Redirect for mobile browser
51. Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv FullBrowserUrl /web_dedicated_site
PerlSetEnv MobileVersion /mobile_dedicated_site
PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site
PerlSetEnv WildCardRedirect true #or false
PerlSetEnv AMFSwitcherExclude /images/,php_test.php
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
AMFSwitcher (redirect in the same site)
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
ApacheMobile Filter Mobile Switcher
Exclude the switcher from some path or file for example:
/images/ or php_test.php the images is not catched by AMFSwitcher
52. Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv FullBrowserUrl /web
PerlSetEnv MobileVersion /mobile
PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site
PerlSetEnv FullBrowserMobileAccessKey fullbrowser #the value you can change
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
AMFSwitcher (redirect in the same site)
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
ApacheMobile Filter Mobile Switcher
This configuration permits to a mobile device to access on Desktop version of the site.
For example in mobile site version you can put this link:
<a href=”/?fullbrowser”>Desktop Version</a>
53. Open the file httpd.conf of your webserver. And configure this few parameters*:
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv FullBrowserUrl /web
PerlSetEnv MobileVersion /mobile
PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site
PerlSetEnv ForceTabletAsFullBrowser true
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFSwitcher
Configuration
AMFSwitcher (redirect in the same site)
*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set
ApacheMobile Filter Mobile Switcher
This configuration permits to a tablet device to access on Desktop version of the site.
56. Configuration
Carrier Detection
PerlSetEnv AMFMobileHome server_root/MobileFilter
PerlSetEnv CarrierNetDownload true #optional#
PerlSetEnv CarrierUrl http://www.andymoore.info/carrier-data.txt
PerlTransHandler +Apache2::AMFCarrierDetection
Open the file httpd.conf of your webserver. And configure this few parameter:
The scope of this module is to identify the Carrier and its nation, and put it as
environment variables called:
AMF_CARRIER_NAME
AMF_CARRIER_NATION
ApacheMobile Filter
Carrier Detection
58. The AMFTrace is working only if is active the WURFLFilter.
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome /server_root/MobileFilter
PerlSetEnv AMFTraceDebug false
PerlModule Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFTrace
Mobile Trace
The goal of this this configuration is to trace (on error_log file) the
UserAgent no detected by AMF
Mobile Trace
or AMFWURFLFilterMemcached
ApacheMobile Filter
59. Mobile Trace
The goal of this this configuration is to trace the wurfl capabities
on error_log file, is useful for statistic scope or debug your
applications.
Mobile Trace
The AMFTrace is working only if is active the WURFLFilter.
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome /server_root/MobileFilter
PerlSetEnv AMFTraceDebug true
PerlSetEnv AMFTraceCapability id,brand_name
PerlModule Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFTrace
or AMFWURFLFilterMemcached
[Mon Mar 22 10:45:42 2010] [warn] [client ::1] AMFTrace - id=mozilla_ver5|brand_name=generic web browser| User_Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; it-it) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7
Example of error_log output:
ApacheMobile Filter
61. WebService
The goal of this this configuration is to give another way to give
capabilities as xml or json.
WebService
The AMFWebService is working only if is active the WURFLFilter.
Open the file httpd.conf of your webserver. And configure this few parameter:
PerlSetEnv AMFMobileHome /server_root/MobileFilter
PerlSetEnv RestMode true
PerlModule Apache2::AMFWURFLFilter
PerlTransHandler +Apache2::AMFWURFLFilter
<Location /WS/*>
SetHandler modperl
PerlResponseHandler Apache2::AMFWebService
Allow from all
</Location>
or AMFWURFLFilterMemcached
ApacheMobile Filter
only from V3.30 before was
PerlOutputFilterHandler
62. WebService
WebService
To have the wurfl capabilities as xml of some device you need to do this get:
GET http://<host>:<port>/WS/?<type=xml>&amf=<user_agent>
To have the wurfl capabilities as json of some device you need to do this get:
GET http://<host>:<port>/WS/?type=json&amf=<user_agent>
To have some capability you can add the capabilityListExample:
GET http://<host>:<port>/WS/?type=json&amf=<user_agent>&capabilityList=<capabiliy 1,capability 2, etc>
ApacheMobile Filter
If you use proxy to access to the AMFwebservice, is suggested to use AMFWSCacheControl. With this
paramerer all proxy cache in middle don’t send many request to webservice. The syntax is:
PerlSetEnv AMFWSCacheControl max-age=2592000
65. How can I retrieve the values of the capabilities of
wurfl?
Retrieve the WURFL capabilities value is very simple all the information are setting into the Apache Environment AMF_<uppercase wurfl capabilities name> for example:
To read the WURFL capabilities max_image_height you must read the environment value AMF_MAX_IMAGE_HEIGHT.
How to read environment in PHP ?
The php code is:
$_SERVER['AMF_MAX_IMAGE_HEIGHT'];
a test page in php is downloadable:
http://mobilefilter.cvs.sourceforge.net/viewvc/mobilefilter/ApacheMobileFilter/test_page/php/php_test.php?view=markup
How to read the value in JSP (for Tomcat)?
Before in the httpd.conf file where you have configure mod_jk you muse add this:
JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined
The Java code is:
request.getAttribute("AMF_MAX_IMAGE_HEIGHT")
How to read the value in PERL?
print $ENV('AMF_MAX_IMAGE_HEIGHT');
ApacheMobile Filter
66. AMF and mod_rewrite
Now AMF is usable with mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html). The mod_rewrite can read the environment
variables that AMF passes.
The most important are:
AMF_DEVICE_IS_MOBILE, AMF_IS_TABLET
Here some example how to use it:
All mobile devices are redirect
In this example you can redirect only the mobile devices to the mobile site:
#Configuration AMF Filter
#
PerlSetEnv AMFMobileHome /usr/local/AMF
PerlSetEnv AMFProductionMode true
PerlSetEnv ServerMemCached localhost:11211
PerlTransHandler +Apache2::AMF<your favorite module>Filter
# or
PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcached
RewriteEngine on
RewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^true
RewriteRule ^(.*)$ http://m.foo.org [R=301,L]
AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter
ApacheMobile Filter
67. AMF and mod_rewrite
All mobile devices are redirect except tablet
In this other example you permit to tablet to access the desktop version:
#Configuration AMF Filter
#
PerlSetEnv AMFMobileHome /usr/local/AMF
PerlSetEnv AMFProductionMode true
PerlSetEnv ServerMemCached localhost:11211
PerlTransHandler +Apache2::AMF<your favorite module>Filter
# or
PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcached
RewriteEngine on
RewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^true
RewriteCond %{ENV:AMF_DEVICE_IS_TABLET} !^true
RewriteRule ^(.*)$ http://m.foo.org [R=301,L]
AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter
ApacheMobile Filter
68. AMF and mod_rewrite
Permit mobile devices to access to desktop
Sometime it’s possible to be able to mobile device to access on PC site, with AMF is simple you need to define the
FullBrowserMobileAccessKey like:
PerlSetEnv FullBrowserMobileAccessKey fullbrowser #the value you can change
and in your mobile page write this link:
<a href=”/?fullbrowser=true”>Desktop Version</a>
In httpd.conf the conditions are:
#Configuration AMF Filter
#
PerlSetEnv AMFMobileHome /usr/local/AMF
PerlSetEnv AMFProductionMode true
PerlSetEnv ServerMemCached localhost:11211
PerlTransHandler +Apache2::AMF<your favorite module>Filter
# or
PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcached
RewriteEngine on
RewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^true
RewriteCond %{ENV:AMF_DEVICE_IS_TABLET} !^true
RewriteCond %{ENV:AMF_FORCE_TO_DESKTOP} !^true
RewriteRule ^(.*)$ http://m.foo.org [R=301,L]
AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter
ApacheMobile Filter
69. Example code in PHP
<?php
if ($_SERVER[AMF_XHTML_SUPPORT_LEVEL] != "-1") {
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Apache Mobile Test</title>
<style type="text/css">
body
{
background-color: #FFFFFF;
font-family: arial, helvetica, sans-serif;
font-size: small;
font-color: #000000
}
</style>
<meta name = "viewport" content = "width = device-width">
</head>
<body>
Welcome to the Apache Mobile Test Page<br/>
<img src="/mobile/header.png" /><br/>
Device data:<br/>
ID: <b><?php echo $_SERVER['AMF_ID'] ?></b><br/><?php echo $tag ?>
Brand name: <b><?php echo $_SERVER['AMF_BRAND_NAME'] ?></b><br/><?php echo $tag ?>
Model name: <b><?php echo $_SERVER['AMF_MODEL_NAME'] ?></b><br/><?php echo $tag ?>
Max Resolution:<b><?php echo $_SERVER['AMF_RESOLUTION_WIDTH'] ?> x <?php echo $_SERVER['AMF_RESOLUTION_HEIGHT'] ?></b><br/><?php echo $tag ?>
Supp. J2ME MIDP 2.0:<b><?php echo $_SERVER['AMF_J2ME_MIDP_2_0'] ?></b><br/><?php echo $tag ?>
</body>
</html>
<?php
} else {
header("Content-type: text/vnd.wap.wml");
print "<?xml version="1.0"?>n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Apache Mobile Test">
<p>Device data:</p>
<p>Brand name: <?php echo $_SERVER['AMF_BRAND_NAME'] ?></p>
<p>Model name: <?php echo $_SERVER['AMF_MODEL_NAME'] ?></p>
<p>Max Resolution Height is <?php echo $_SERVER['AMF_RESOLUTION_HEIGHT'] ?></p>
<p>Max Resolution Width is <?php echo $_SERVER['AMF_RESOLUTION_WIDTH'] ?></p>
</card>
</wml>
<?php
}
?>
XHTML Version
WML Version
check if the device supporto XHTML
image rendering
ApacheMobile Filter
71. Who talks about “Apache Mobile Filter”
• “Gestire i dispositivi mobili con Apache Mobile Filter” (http://www.html.it/articoli/gestire-
i-dispositivi-mobili-con-apache-mobile-filter/)
• “The Case of Open Source Development, a Personal Case Study” (http://
robertogaloppini.net/2009/01/20/the-case-for-open-source-development-a-personal-
case-study/)
• “Apache Mobile Filter” (http://mobilephonedevelopment.com/archives/854)
• “Un progetto italiano per l’identificazione dei dispositivi mobili” (http://
www.blographik.it/2009/06/24/un-progetto-italiano-per-lidentificazione-dei-dispositivi-
mobili/)
• “Apache Mobile Filter” (http://www.open4dev.com/journal/2009/6/29/apache-mobile-
filter.html)
ApacheMobile Filter