I would recommend reading up on
responsive web design instead. Puts more pressure on the coder, but will be more fluid and easier to maintain in the future.
Should you not want that it's really just about getting the User Agent string from the client browser ($_SERVER['HTTP_USER_AGENT'] in PHP) and checking if it's a mobile browser (mostly checking if it contains iOS or Android I guess, there are comprehensive user agent lists online) and if it is then redirect (header('Location: <url>') in PHP)