We help IT Professionals succeed at work.

iPhone page redirect

matreece
matreece used Ask the Experts™
on
I have an index page that contains a Flash intro but I want iPhone users to be able to skip this page and take them straight into the main site. I have tried various Javascript examples which worked, but then realised most iPhones don't have Javascript turned on. So I'm now looking at PHP solutions.

The code I'm dropping into my php page is:

<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod'))  
{
 header('Location: about.html');
 exit();
 }
 ?>

This is taken from - http://davidwalsh.name/detect-iphone

However it doesn't seem to be working.

Can anyone help where this code should be placed (body, header ?) or if there is a different example that will work.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
make sure it is placed befory you output anything to the client.

as soon as you send a single character to the client you will be unable to sond headers and therefore unable to send the location redirect header.
Also, I do agree that a serverside solution is preferred over a javascript solution, but almost all iphones have javascript enabled.

Author

Commented:
Great, thanks