About the author : Daniel Griffith

Daniel is an Author, Designer, and Entrepreneur. With over 10 years of industry experience, Daniel utilizes his unique blend of mathematics and poetry, engineering and creative thinking to solve both technical and business challenges to ultimately co-create the world he wants to live in.

The 2 most common methods of redirecting a mobile device from a normal, desktop version of the website to an optimized mobile website are:

  1. JavaScript
  2. PHP

Use the site below as a reference as you work through whichever method you feel will work best for your web site.

http://detectmobilebrowsers.com/


Method 1: JAVASCRIPT

A prototype-based scripting language that is dynamic, weakly typed and has first-class functions.

Setup:

  1. Download latest “detectmobilebrowser.js.txt” from the website above.
  2. Open the file you just downloaded.
  3. At the bottom of the document change the URL from “http://detectmobilebrowser.com/mobile” to the desired URL for your mobile site.
  4. Save changes and close the file.
  5. Right click and rename file and remove “.txt” from “detectmobilebrowser.js.txt” so it looks like “detectmobilebrowser.js”.
  6. Upload file to where your main website “index” file is at.

Making It Work:

  1. Go into your main website’s “index” file.
  2. Add “<script type=”text/javascript” src=”detectmobilebrowser.js”></script>” inside the header of your “index”.
  3. Save all changes and upload your “index” file to your FTP.

Method 2: PHP

Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development.

Setup:

  1. Download latest “detectmobilebrowser.php.txt” from the website above.
  2. Open the file you just downloaded.
  3. At the bottom of the document change the URL from “http://detectmobilebrowser.com/mobile” to the desired URL for your mobile site.
  4. Copy all the text in the document to your clipboard.

Making It Work:

  1. Go into your main website’s “index.php” file.
  2. Paste what you just copied in the header of your “index.php” file.
  3. Save all changes and upload your “index.php” file to your FTP.

BONUS TIP: If you visit http://detectmobilebrowsers.com/ on a mobile device it will tell you what mobile device, operating system, and browser you are running.