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!
Article Sponsored by:
Covering everything from getting started to expanding your business, How to Be a Rockstar Freelancer is the official FreelanceSwitch book. Written by Collis and Cyan Ta'eed - the founders of the site.









Quick, easy, not big and nice; this is what I call a Mobile tutorial
. Thanks Brian.
Well said
Thanks for the comments!
If I create an iphone page and do an autoredirect to it, how can I link back to the main site? I’m using a joomla site, so all pages on the site use the index.php?pagename idea, so whenever I try to access another page on the site, I’m taken back to the iphone specific home page.
I tried implementing this code but I got an error when I tested on my iphone:
Safari cannot open page because too many redirects occurred.
How do I fix this? Thanks!
I’m getting the same issue on the iPhone… too many redirects…
I would love for this to work because of the sheer simplicity!
Any fix on this?
I am getting
Warning: Cannot modify header information – headers already sent by (output started at /home/content
and I have checked for white spaces
Nevermind, wrong forum.