Hi, I want to redirect a visitor using an iphone to a separate iphone subdomain. I have added the following code to the top of a webpage but the page then does not load at all. I put the code hard top left of the page. Is there something else that i need to do?
<?php
//setting the variables
$ipod = stripos($_SERVER['HTTP_USER_AGENT'],”iPod”);
$iphone = stripos($_SERVER['HTTP_USER_AGENT'],”iPhone”);
//detecting device
if ($ipod == true || $iphone == true){
header( ‘Location: http://www.m.abbyeagle.com/’ ) ;
} else {
header( ‘Location: http://www.abbyeagle.com/styles/index.php/’ ) ;
}
?>
iPhone detection and redirection with php
Moderator: General Moderators
Re: iPhone detection and redirection with php
Are you getting an error message? Perhaps you're stuck in an endless loop somehow?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: iPhone detection and redirection with php
This will need to be at the very top of the page before <html... or anything else. Also, you need an exit; after each of your header() calls.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.