Solved

How do I use Apache to redirect mobile phones to external site without js or php?

Posted on 2008-10-27
5
1,975 Views
Last Modified: 2013-11-10
My client is running Apache 2.2.6 on RHEL 5 on i686 arch. I've been tasked with doing a redirect to an external URL if a user connects to our site using a WAP device (or a third site if they're coming in via iPhone) that are hosted by a third party content provider.

I am getting push back from the development team in terms of injecting a .js in front of the index page load, and there is no PHP anywhere in the environment, so I appear to have to fall back onto Apache's capabilities.

The Apache configuration already makes liberal use of mod_rewrite, so rewrites are not a problem. I appear to have a couple of options:

1. some form of RewriteCond %(HTTP_USER_AGENT) where I look for a browser type and redirect  externally with a RewriteRule afterwards. This seems difficult due to the amount of browser types there are on mobile phones. Perhaps there a common string?

Here's a list of agent's I'd probably have to sort through:

http://www.zytrax.com/tech/web/mobile_ids.html

Looks like I could use a couple strings, with contents like like "MIDP" and "240x320". Still not elegant.

2. Some sort of Content Negotiation? I'm not sure how to take this from idea to code.

3. Demand the developers add a .js detection script to be run before initial page rendering. The web application itself runs on JBoss 4.5 with a jre 1.5 container.

Anyone have any tips on this?
0
Comment
Question by:cskow
  • 3
5 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 250 total points
ID: 22812976
to detect the iphone you will need to look at its USER_AGENT signature to see if has "iPhone" somewhere in it. Thus you will explicitly need to look for that "iPhone" value. As for the other devices, refer to:
http://hungrycoder.xenexbd.com/node/182
0
 

Author Comment

by:cskow
ID: 22815860
I think I will end up using something like this:


RewriteCond %{HTTP_USER_AGENT} *iPhone* [OR]
RewriteCond %{HTTP_USER_AGENT} *BlackBerry* [OR]
RewriteCond %{HTTP_USER_AGENT} *Windows CE* [OR]
RewriteCond %{HTTP_USER_AGENT} *LG* [OR]
RewriteCond %{HTTP_USER_AGENT} *HTC* [OR]
RewriteCond %{HTTP_USER_AGENT} *MOT* [OR]
RewriteCond %{HTTP_USER_AGENT} *Motorola* [OR]
RewriteCond %{HTTP_USER_AGENT} *Nokia* [OR]
RewriteCond %{HTTP_USER_AGENT} *Samsung* [OR]
RewriteCond %{HTTP_USER_AGENT} *SonyEricsson* [OR]
RewriteCond %{HTTP_USER_AGENT} *Palm* [OR]
RewriteCond %{HTTP_USER_AGENT} *Symbian*
RewriteRule ^/$ http://wap.externalsite.com [L,R=301]
0
 

Author Comment

by:cskow
ID: 22815867
I will post after I get a chance to validate
0
 

Author Comment

by:cskow
ID: 22836133
In the end I used this string:

 RewriteCond %{HTTP_user_agent} ^(DoCoMo|J-PHONE|KDDI|UP.Browser|DDIPOCKET|.*iPhone.*|.*iPod.*|.*BlackBerry.*|.*Windows.CE.*|.*LG.*|.*HTC.*|.*MOT.*|.*Motorola.*|.*Nokia.*|.*Samsung.*|.*SonyEricsson.*|.*Palm.*|.*Symbian.*) [NC]
 RewriteRule (.*)  http://www.remotesite.com/ [R,L]
0
 

Expert Comment

by:elvis00
ID: 23255420
Hi,
check the WURFL database on http://wurfl.sourceforge.net/ there you find at least a lot of user agents which you can use as forward rule.

Cheers
Markus
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CFFILE upload help 98 138
SSL sertificate 5 58
Setting up a WAMP server... 7 55
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 56
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now