Grow your CSS skills. Land your dream job.

Last updated on:

iPhone Catcher

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*iPhone.*
RewriteRule ^index\.html$ [L]
RewriteRule  ^/$ [L]


  1. Andrew
    Permalink to comment#

    Some implemention instructions would be nice.

  2. Permalink to comment#

    It looks like all you would have to do is create a .htaccess file on the root directory of the site you would want to redirect for iPhones. Copy the above code into the file and change the fourth line where it says “” to where you would want it to redirect to. And then create whatever alternate page the iPhone would go. Also make sure that on the fith line the “” is changed to your domain.

  3. Remember that the iPod touch probably wants to be redirected as well, and that it’s UA has iPod instead of iPhone…

  4. thanks for adding the textmate snippet link – thats a classy addition of which i’ve seen nowhere else :)

  5. I’m thinking this may be useful to serve responsive images if you add the filter for image file types and increase the amount of browsers in the query string, or or just query user agents that contain the string “mobile”

    I know User Agent strings aren’t’ the best way to detect mobile browsers, but realistically people spoofing their user agent string are edge cases

  6. Permalink to comment#

    cool! this might help serving responsive images as Richard says, saving some bandwidth for visitor and server both.

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like ```this```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".