Redirect iPhone’s with Javascript

Here is a really quick code:

  <script type="text/javascript">
  if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    location.href='YOUR_DIRECTORY/';
  }
  </script>

Add this to your html document’s head section. Replace YOUR_DIRECTORY with the folder that contains your iPhone optimized site.