Mod rewrite integration

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

From AMF Wiki

With Apache Mobile Filter is possible to use for redirect 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 importants are:

AMF_DEVICE_IS_MOBILE, AMF_IS_TABLET

Contents

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]

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]

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

Another solution for redirect is to use AMFSwitcher

Using mod_rewrite and Drupal

A good documentation about using AMF with Drupal is here: http://drupal.org/node/1475760

Configuration AMF+ filter
AMF and mod_rewrite
Personal tools