Skip to content

Instantly share code, notes, and snippets.

@wpjess
Created September 26, 2020 05:01
Show Gist options
  • Save wpjess/47a3dcd62ee41c0f62c618d3992945d9 to your computer and use it in GitHub Desktop.
Save wpjess/47a3dcd62ee41c0f62c618d3992945d9 to your computer and use it in GitHub Desktop.
Redirect page based on device type
<?php
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
if( $iPod || $iPhone || $iPad){
header( 'Location: https://facebook.com' );
die();
}
else if($Android){
header( 'Location: https://google.com' );
die();
}
else
{
die();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment