Skip to content

Instantly share code, notes, and snippets.

@dmolsen
Created May 21, 2012 14:47
Show Gist options
  • Select an option

  • Save dmolsen/2762726 to your computer and use it in GitHub Desktop.

Select an option

Save dmolsen/2762726 to your computer and use it in GitHub Desktop.
Using ua-parser-php for a redirect script
<?php
// require the ua-parser-php library
require_once("/path/to/UAParser.php");
// parse the requesting user agent
$result = UA::parse();
// redirect phones, to redirect tablets use isMobileDevice
if ($result->isMobile) {
header("location:http://dmolsen.com");
}
// run through the rest of your code for the page for desktop devices & spiders
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment