1

I'm having a problem. After reading all of this post I'm trying to implement a redirect ONLY for WAP devices that don't support modern browser capabilities.

For example, I want an old BlackBerry to use this redirect but not an Android or iPhone device.

RewriteEngine On

RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile}       !^$

RewriteCond %{REQUEST_URI}          !^/wap/?$
RewriteRule ^ http://example.com/wap/ [R,L]

The issue is that this rule redirects all mobile devices. Can I explude modern browsers anyway?

Thanks!

Community
  • 1
  • 1

1 Answers1

0

This will work I used on my wordpress site to redirect to my mobile site m.mysite.com

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>



Options +FollowSymlinks
RewriteEngine on
RewriteBase /

# prevent looping
RewriteCond %{HTTP_HOST} !^m.mysite.com$

# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]

# a bunch of user agent tests
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]

# rewrite rules here
RewriteRule ^(.+)\$ http://m.mysite.com/$1 [R=302,NC] 

You may have to modify someparts if need be.

Jack Siro
  • 677
  • 10
  • 29