Mod amf

[article] [edit page] [discussion] [history]

From AMF Wiki

Contents

Overview

The mod_amf is a C version of AMFLiteDetection and is the fastest way to detect mobile devices.

mod_amf is suggested to use for solution that not need exactly the type of device, but only if the device is mobile, is a tablet or touch device. Is not require a Device Repository but only to access to our web services.

The modules does this three steps:

  • load data additinal parameter from apachemobilefilter.org online service (isfree)
  • could be manage to force mobile device to full browser layout.

mod_amf

The first step is to define the AMFHome this is important for AMF because in this directory the AMF store all file .

In httpd.conf of Apache you define this parameter:

<IfModule mod_amf.c>
   AMFHome /Users/idelfuschini/SVILUPPO_PLUGIN/apache2_dev/Apache2/AMF_Home 
   AMFActivate on
</IfModule>

where AMFHome must be writeable. For activate or deactivate AMF, the default value is "on".

At the start AMF download the files configuration from Apache Mobile Filter official site, if apache can't connect to the website, you can disable the download with AMFDownloadParam (default value if "on".

<IfModule mod_amf.c>
   AMFHome /Users/idelfuschini/SVILUPPO_PLUGIN/apache2_dev/Apache2/AMF_Home 
   AMFActivate on
   AMFDownloadParam off
</IfModule>

Download repository through proxy

If your server is behind a proxy set this configuration:

<IfModule mod_amf.c>
   AMFHome /Users/idelfuschini/SVILUPPO_PLUGIN/apache2_dev/Apache2/AMF_Home 
   AMFActivate on
   AMFDownloadParam off
</IfModule>

To increase performance of AMF in production environment put the AMFProduction environment in this mode:

AMFProduction on

if you want to force some device (for example tablet) to be able to access to desktop version you can set the AMF+ with this configuration:

<IfModule mod_amf.c>
   AMFHome /Users/idelfuschini/SVILUPPO_PLUGIN/apache2_dev/Apache2/AMF_Home 
   AMFProxy http://10.6.222.1:3128
   AMFProxyUsr lottomatica\e2326
   AMFProxyPwd giaki!1998
   AMFDownloadParam on
   AMFFullBrowser on
   AMFActivate on
</IfModule>

NOTE: AMFProxy,AMFProxyUsr,AMFProxyPwd must be setted before AMFDownloadParam directive

Apache configured as Worker

If your apache is configured as worker is suggested to switch off AMFLog:

AMFLog off

Disable verbose mode

With AMF Log directive it's possible to disable verbose mode default is on:

AMFLog off

Desktop Force

In this mode in your site you can make a simple link like this:

<a href=”/?desktop=true”>Desktop Version</a>

in this mode the AMF+ add the new environment variable FORCE_TO_DESKTOP setted with "true" value.


Which info AMF+ give to you ?

There are few but important info that AMF+ give as environment variable:

AMF_DEVICE_IS_MOBILE (true/false)

AMF_DEVICE_IS_TABLET (true/false)

AMF_DEVICE_IS_TOUCH (true/false)

AMF_DEVICE_MOBILE_OS (deprecated from 1.3.2)

AMF_DEVICE_MOBILE_OS_VERSION (deprecated from 1.3.2)

AMF_FORCE_TO_DESKTOP (true/false)

AMF_DEVICE_IS_TV (true/false)

AMF_DEVICE_IS_DESKTOP (true/false)

AMF_DEVICE_OS (from 1.3.2)

AMF_DEVICE_OS_VERSION (from 1.3.2)

AMF_BROWSER_TYPE (from 1.3.2)

AMF_BROWSER_VERSION (from 1.3.2)

It's possible to use AMF+ with mod_rewrite  ?

Yes it's possible below a tipical example of how to use it:

RewriteCond %{ENV:AMF_DEVICE_IS_MOBILE}  =true
RewriteCond %{ENV:AMF_DEVICE_IS_TABLET}  =false
RewriteCond %{ENV:AMF_FORCE_TO_DESKTOP}  !=true
RewriteRule (.*) "https://mobile.site.com" [R=301,L,NE]

in this case you redirect all mobile devices except tablet, and also you can manage the case if some mobile user want to see the desktop version of your site.

AMF directive

AMFHome

AMFActivate

AMFLog

AMFFullBrowser

AMFFullBrowserAccessKey

AMFDownloadParam

AMFmobile

AMFtouch

AMFtablet

AMFtv

AMFProxy

AMFProxyUsr

AMFProduction

AMFProxyPwd

How can I retrieve the values of the capabilities ?

Retrieve the AMF capabilities value is very simple, all the informations are setting into the Apache Environment as AMF_<uppercase AMF capabilities name> for example:

To read the DetectRight capabilities AMF_IS_MOBILE you must read the environment value AMF_MAX_IMAGE_HEIGHT.

How to read environment in PHP ?Php.jpg

The php code is:

$_SERVER['AMF_DEVICE_IS_MOBILE']; 

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)? Tomcat.jpg

Before in the httpd.conf file where you have to configure mod_jk you muse add this:

JkEnvVar AMF_DEVICE_IS_MOBILE undefined

The Java code is:

request.getAttribute("AMF_DEVICE_IS_MOBILE")

How to read the value in PERL? Cpan2.png

print $ENV('AMF_DEVICE_IS_MOBILE');
Configuration AMF+ filter
AMF and mod_rewrite
Personal tools