Forum Moderators: phranque

Message Too Old, No Replies

Need help .htaccess redirec mobile but not Ipad or andoid HD

dont want my htaccess redirect all mobile pages to Ipad

         

binhaus

1:07 am on Jan 18, 2011 (gmt 0)

10+ Year Member



dear
Fist thank for mem how help me out for this
[webmasterworld.com...]
that redirect all mobile webbrowser to corect mobile webpage on my site.

#Redirect if mobile device
RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]

RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]+)$

RewriteRule ^modules\.php$ http://www.example.com/modules.php?name=News&file=article_mobi&sid=%1 [R=301,L]




But there are issue come up.

I just need redirect the small mobile like Iphone, HTC ..
But not for Ipad, Samsung galaxy tab, Or other Tablet devices ..

any way work around with htaccess.

thank

jdMorgan

11:04 pm on Jan 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You must adjust the first RewriteCond to match the user-agent strings for phones that you do want to redirect, and to NOT match the user-agent strings of phones that you do NOT want to redirect.
Alternately, leave the original RewriteCond as it is, and add a negative-match rewritecond to exclude the phones you don't want to redirect. Something like:

RewriteCond %{HTTP_USER_AGENT} !iPad|Galaxy\ Tab [NC]

Unless you plan to study mobile user-agent strings and learn about mod_rewrite and regular-expressions in detail, or to hire someone to maintain this code, I suggest that you drop this mobile-site idea. You will likely need to update this code at least weekly to keep up with all the new phone models...

Jim

binhaus

5:42 am on Jan 20, 2011 (gmt 0)

10+ Year Member



you r rock .. thank a ton

notice that .. the Galaxy Tab will not work..
I use the "GT-P1000" .

I love this small code that will not take much resouce of server like php script check httpd header user agent.

I just severving all main tablet gadget which popular on market, all other mobile device will redirect to mobile webpage :)
thanks again