Redirect iPhone, Blackberry, & Palm Requests With .htaccess

Monday, January 26th, 2009

So you wanna serve a separate page or sub domain for mobile phones? Add this bit of fun to your .htaccess and you're rockin'. All iPhone, Blackberry, & Palm requests will go to a mobile subdomain.

#redirect mobile browsers
RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]

If you enjoyed this article, you might consider subscribing to our rss feed to stay updated with all the latest tips and articles!

ABOUT THIS AUTHOR

Brian Cray is a marketing & Internet strategy consultant, web developer, and Apple fanatic living in Columbus, Ohio, USA. His work has been featured by Mashable, NETTUTS, Smashing Magazine, and many others. He's happy to share his knowledge with you on DevTips and his own blog at Brian Cray.com.
  1. Wassim
    January 30, 2009 at 4:06 pm
  2. January 30, 2009 at 4:09 pm
  3. kev
    February 23, 2009 at 4:42 pm
  4. September 4, 2009 at 5:16 pm
  5. October 12, 2009 at 8:35 pm
  6. hwkd65
    November 17, 2009 at 9:52 am
    • hwkd65
      November 17, 2009 at 9:54 am

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Popular Series

Output Buffering Articles
Build a Custom AJAX and PHP Contact Form
The Ultimate Image Gallery Manager.
ThemeForest Premium Site and WordPress Templates