0

I can't get this redirect to function:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} iPad|iPod|iPhone|Android|s+Mobile
RewriteRule .* mobile.php

I'm testing it using my Android phone, and also using the user-agent switcher in Google Chrome dev version.

I tried AllowOverride All but it makes the server, running Zeus, reply with an access denied message.

It is a shared host and so I do not really have access to any server logs that I know about.

random
  • 9,774
  • 10
  • 66
  • 83
Jason
  • 15,064
  • 15
  • 65
  • 105

2 Answers2

0

Redirect mobile browsers

RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://m.example.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://m.example.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$
RewriteRule ^(.*)$ http://m.example.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://blackberry.example.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*IEMobile.*$
RewriteRule ^(.*)$ http://ie.example.com [R=301]
random
  • 9,774
  • 10
  • 66
  • 83
Jason Weber
  • 5,653
  • 6
  • 40
  • 73
  • Nice list, s+Mobile is also relevant - this targets devices that are not android/ipad/iphone or just mobile browsers that run on multiple oses – Jason Feb 13 '14 at 21:51
0

The problem was that i was running Zeus... not apache. It doesn't support .htaccess.

see: How can I rewrite URLs in the Zeus web server for Mobile useragent?

Community
  • 1
  • 1
Jason
  • 15,064
  • 15
  • 65
  • 105