Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created January 30, 2013 18:56
Show Gist options
  • Save alanleard/4675718 to your computer and use it in GitHub Desktop.
Save alanleard/4675718 to your computer and use it in GitHub Desktop.
Mobile App PHP redirect
<?php
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
header('Location: https://MyAndroidAppURL');
exit();
} else if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad'))
{
header('Location: http://MyiTunesAppURL');
exit();
} else {
header('Location: http://MyWebsite');
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment