How to Detect and Redirect iPhone Traffic Using HTACCESS

Posted by Systems Cowboy on September 11, 2010

Sometimes it’s a good idea to detect visitors who are viewing your site on an iPhone and redirect them to content that is more tailored to their device. Here’s a really easy way to do that using HTACCESS. Just create an .htaccess file and drop it in the root directory of your website (or add these lines to your existing .htaccess file):

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteRule .* http://www.myiphonesite.com [R]

This code will automatically detect visitors who are using an iphone and redirect them to the content you specified. It’s that easy.

For a very basic example of this, use your iPhone to visit this iPhone casino site.

Add Your Comment