redirect mobile users (ipad and android) to a m.domain.com?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 07 Sep 2013, 18:48

redirect mobile users (ipad and android) to a m.domain.com?

07 Sep 2013, 18:51

Hi,

beginner question.. would it be possible to redirect (only) the mobile users to a different subdomain using rewrite3 on iis6?

im not quite sure how to do it but it seems todo with user-agent header and searching for 'midp|mobile|phone|android|iphone|ipad'

anyone know how to do this?

User avatar
Posts: 3
Joined: 07 Sep 2013, 18:48

Re: redirect mobile users (ipad and android) to a m.domain.c

09 Sep 2013, 05:45

could it be like this ?

Code: Select all
RewriteCond %{HTTP:User-Agent} (midp|mobile|phone|android|iphone|ipad)
RewriteRule (.*) http://m.domain.com


idea is to take all mobile users to m.domain.com

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: redirect mobile users (ipad and android) to a m.domain.c

09 Sep 2013, 07:04

Yes, your code is good. Let's make it a little more precise like this:

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (?:midp|mobile|phone|android|iphone|ipad) [NC]
RewriteRule (.*) http://m.domain.com/$1 [R=301,L]

User avatar
Posts: 3
Joined: 07 Sep 2013, 18:48

Re: redirect mobile users (ipad and android) to a m.domain.c

09 Sep 2013, 07:37

thank you for helping me, and making things even better.

not quite understand one part of the RewriteRule : '$1 [R=301,L]

Does it have something to do with keeping the postfix URL? like http://www.domain.com/$1 to m.domain.com/$1 for example: http://www.domain.com/game/play.php to http://m.domain.com/game/play.php ?

in my case i rather have all mobiel users to land exactly on http://m.domain.com no matter the URL location, because all my content is no use for them (its a flash game website)

Would it be like this in my case? should [R=301,L] be kept in the rule or not?..

Code: Select all
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (?:midp|mobile|phone|android|iphone|ipad) [NC]
RewriteRule (.*) http://m.domain.com

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: redirect mobile users (ipad and android) to a m.domain.c

10 Sep 2013, 06:58

If you want all requests to land on the home page, then your config is correct, but I suggest leaving [R=301,L]:

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (?:midp|mobile|phone|android|iphone|ipad) [NC]
RewriteRule (.*) http://m.domain.com [R=301,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 14 guests