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:
At ThemeForest you can buy and sell site templates and themes to skin popular CMS products like WordPress, Drupal and Joomla. Files are priced from just five dollars, based on the complexity, quality and use of the file. Check it out today!
14 Comments
subscribe comments feedTrackbacks/Pingbacks
- AndySowards.com :: Web Development Nerdy Daily Links For 1/27/2009 | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster?
- iPad Detection Using JavaScript or PHP | Shop Rate
- Is cooming » Blog Archive » iPad Detection Using JavaScript or PHP
- Redirigir iPhone, Blackberry y Palm desde .htaccess | Sentido Web








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.
hi, you forgot to add:
RewriteEngine on
in a first line. It may be required if it’s not globally on
Haha no bodies understand how to use it ….
If you have a too many redirections that means you try to redirect the user to the same domain with the same htaccess and here the loop!
The solution is too redirect the user to anohter domain with no htaccess or to redirect the user to an mobile.html page and to add a condition at the top of your htaccess.
I cannot post the complete code due to my company … but the idea is here
Thanks a lot.