So I've read there are several different ways to do this using HTML, JS, PHP, Cookies, etc... and found a discussion suggesting to search for "javascript detect mobile browser" which I did, and maybe since the forum is from 2010 the search results are lacking ...here is a link to that forum: http://forums.adobe.com/message/3172216#3172216.
I have code and editing knowlege but not on the developer side of things...I could not write a JS, or PHP if needed...but have created a jQuery mobile site no problem!
Thanks!
~Jenny
we are in the process of finalizing our mobile website which is m.domain.com and was told by our server/host that they always have "some sort of code" (of which they will not share with us) on the home page of the www.domain.com so that mobile users will be redirected to the m.domain.com site.
btw Nancy - I want to thank you for all your help you have provided us and I'm sure to others on these posts...I see your name a lot!
this server/host should have our m.website live by the end of today...
Jenny
I'm afraid my comprehension of all this is very limited...there are several options like PHP, CFML, and ASP - but how do I know which one is right for my website? From what I've read PHP is only if your pages end in .php, but ours do not...after lots of research yesterday it sounded like a JS file would be the best for us... our desktop website is www.whitewatertours.com.
This website seemed like it would be an easy fix for a JS code: http://detectmobilebrowsers.com/ - has anyone used that site?
Jenny
If your site is hosted on a Linux server, you could use .htaccess or PHP redirect. Client side script (js) is not as reliable because the end user must have JavaScript enabled or it won't work.
Nancy O.
If you can utilize .htaccess, the following may be helpful, especially in cases where you might want to link to the main site from the mobile version. I've used a variation of this code on two mobile projects: http://webdesignandsuch.com/redirect-to-a-mobile-site-with-htaccess-an d-set-a-cookie-to-break-redirect/
You could use either JavaScript or PHP to do this but I prefer PHP, as Nancy said JavaScript can be a bit shakey to say the least across different devices and it may not be enabled.
I have come across a few ways to this but my preferred choice is a project called MobileESP. This project offers a JavaScript or a PHP solution for detecting a massive array of different devices. Because of how complex this project is, I thought I'd explain a very basic way of using the scripts to redirect the client to the appropriate page dependant on what type of device the client is using. PHP is the best solution for this. This script was acquired from there site.
Go to http://blog.mobileesp.com/ and download the PHP version of MobileESP which is a file called mdetect.php.
Put this file in a folder called scripts.
Then for your index.php home page at the site root, add this script below,
<?php
include("/scripts/mdetect.php");
//Instantiate the object to do our testing with.
$uagent_obj = new uagent_info();
//Detect iPhone Tier and iPads...
if (($uagent_obj->DetectTierIphone() == $uagent_obj->true) ||
($uagent_obj->DetectIpad() == $uagent_obj->true))
{ header('Location: http://www.yoursite.com/i/'); } //Edit here
//Detect Rich CSS Tier...
else if ($uagent_obj->DetectTierRichCss() == $uagent_obj->true)
{ header('Location: http://www.yoursite.com/r/'); } //Edit here
//Detect All Other Mobile Devices...
else if ($uagent_obj->DetectTierOtherPhones() == $uagent_obj->true)
{ header('Location: http://www.yoursite.com/m/'); } //Edit here
//Else it's a regular PC browser -- send to regular desktop site
else
{ header('Location: http://www.yoursite.com/d/'); } //Edit here
?>
This script redirects iPhone Tier devices and iPads to www.yoursite.com/i/, Rich CSS devices such as Nokia N95 to www.yoursite.com/r/, Generic mobile devices to www.yoursite.com/m/ and Desktop browsers and all others to www.yoursite.com/d/.
You can also redirect to any file i.e. www.yoursite.com/d/index.html or www.yoursite.com/d/index.js.
Hopefully this should answer your question.
![]()
I would mention that Project 7 has a mobile detection script that runs correctly, written in JavaScript. And then what they do is they change how the website looks in CSS. That way they don't have to support mobile in a separate website.
This technology is in Page Builder Magic and in their Adaptations websites. For very little cost, their templates can give you mobile capabilities without any of the headaches, assuming time is money.
North America
Europe, Middle East and Africa
Asia Pacific