War Room


Go Back   WarriorForum - Internet Marketing Forums > The Warrior Forum > Mobile Marketing
Register Blogs FAQ Community CalendarHelp Desk

Reply
 
Share
LinkBack Thread Tools
Old 02-17-2013, 10:35 AM   #1
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default PHP Mobile Detect/Redirect and View Full Site

Anyone got a working solution for this?

I've tried several different mobile detect sripts and redirects and have gotten them all to work. What I need is if I put a link to View Full Site on the mobile page for the user to be able to click that link and go to the full site not once again be redirected back to the mobile version.

The closest solution I have been able to find is: PHP Mobile Redirect and View Full Site

But even that one doesn't work atleast not for me.

I know there's someone out there that knows of a working solution.

Thanks,
Erick
EZE522 is offline   Reply With Quote
Old 02-17-2013, 06:23 PM   #2
HyperActive Warrior
 
Join Date: Mar 2007
Location: , , Canada.
Posts: 492
Thanks: 2
Thanked 77 Times in 67 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

I use HandHeld from elegantthemes.

Once i click on full site, you scroll to the bottom and its shows up a blue line to click back to mobile view.
crams is online now   Reply With Quote
Old 02-17-2013, 09:42 PM   #3
Warrior Member
 
Join Date: Mar 2008
Posts: 16
Thanks: 6
Thanked 10 Times in 9 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

You would just include a variable check before the redirection code and then include it in the link from the mobile site ( eg. http://www.yoursite.com?fs=true ).

ND
nesterdwarf is online now   Reply With Quote
Old 02-17-2013, 10:18 PM   #4
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default Re: PHP Mobile Detect/Redirect and View Full Site

Quote:
Originally Posted by nesterdwarf View Post
You would just include a variable check before the redirection code and then include it in the link from the mobile site ( eg. http://www.yoursite.com?fs=true ).

ND
Ok, I'm a bit of a novice when it comes to code. I kind of understand what you are saying but how to code it I wouldn't have a clue. I can copy and paste with the best of them tho...lol
EZE522 is offline   Reply With Quote
Old 02-17-2013, 10:21 PM   #5
You reap what you sow.
War Room Member
 
Nail Yener's Avatar
 
Join Date: May 2008
Posts: 852
Thanks: 172
Thanked 352 Times in 212 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

Quote:
Originally Posted by EZE522 View Post
Anyone got a working solution for this?

I've tried several different mobile detect sripts and redirects and have gotten them all to work. What I need is if I put a link to View Full Site on the mobile page for the user to be able to click that link and go to the full site not once again be redirected back to the mobile version.

The closest solution I have been able to find is: PHP Mobile Redirect and View Full Site

But even that one doesn't work atleast not for me.

I know there's someone out there that knows of a working solution.

Thanks,
Erick
I use the cookie concept explained in the link that you gave in my designs and templates. If you do it right, it should work. Setting a cookie is the only PHP solution I could came up with after a considerable amount of research.

If you want a "copy+paste" code, you should try asking in coding forums but even in such forums I don't think you will get an answer.

"...CLOSED A SALE while I was testing this tool in the beta testing period..."

Mobile Landing Pages | Premium Mobile Website Templates
"..amazing!.." "..super fast.." "..best of this style.."
Nail Yener is offline   Reply With Quote
Old 02-17-2013, 10:35 PM   #6
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default Re: PHP Mobile Detect/Redirect and View Full Site

I've currently got this code in my header.php at the very top:

<?php
@include("Mobile_Detect.php");
$detect = new Mobile_Detect();
if ($detect->isMobile() && isset($_COOKIE['mobile']))
{
$detect = "false";
}
elseif ($detect->isMobile())
{
header("Location:http://m.mobilesite.com");
}
?>

I've got the following code in my mobile sites index at the very top:

<?php
setcookie("mobile","m", time()+3600, "/",".fullsite.com");
?>

I've got the Mobile_Detect.php in my main sites root folder.

This is the code I have at the bottom of my mobile pages:
<a id="footer-fullsite" href="http://fullsite.com/">Desktop</a>/<a id="footer-fullsite" href="">Mobile</a>


Maybe I'm doing something wrong? Another set of eyes never hurts.
EZE522 is offline   Reply With Quote
Old 02-18-2013, 09:04 AM   #7
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: Jul 2006
Location: USA
Posts: 2,811
Thanks: 208
Thanked 1,363 Times in 677 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

Quote:
Originally Posted by Nail Yener View Post
Setting a cookie is the only PHP solution I could came up with after a considerable amount of research.
In my opinion the best way to do this is to use a combination of cookies AND sessions, because some mobile visitors will clean their cookies between subsequent visits to your site, and some will have cookies blocked altogether.

So for your mobile visitors who choose to view your full site (and not get stuck in an endless redirect loop)... you first check to see if your cookie has been saved on their device. If so, you use that to set the redirect "flag". If not, then you can set the flag via sessions or via the query string (which of course will only work for as long as they stay on your site, but it's better than nothing).

Brandon Tanner is offline   Reply With Quote
Old 02-18-2013, 10:25 AM   #8
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: Nov 2011
Location: Spain
Posts: 735
Thanks: 97
Thanked 198 Times in 171 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
Default Re: PHP Mobile Detect/Redirect and View Full Site

I would go with cookies and PHP sessions, too.

All those scripts just check the UA, route to the websites and saving preferences can only be done via cookies. If no cookie is saved...

HTML/CSS/jQuery/ZURB Foundation 3/Twitter Bootstrap 2/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is offline   Reply With Quote
Old 02-18-2013, 11:18 AM   #9
Warrior Member
Registered Member
 
Join Date: Jan 2013
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

If you follow these instructions you will have a functioning mobile redirect on your site:

First, go to the following URL and download the mobile_detect.php file:

php-mobile-detect - The lightweight PHP class for detecting mobile devices. - Google Project Hosting

Next, follow the instructions on the page, and upload the mobile_detect.php to your root directory.
Dougbrysun..
dougbrysun is offline   Reply With Quote
Old 02-18-2013, 12:55 PM   #10
webstylecreator.com
War Room Member
 
MagicAce's Avatar
 
Join Date: Jun 2010
Location: Torino, Italy
Posts: 683
Thanks: 58
Thanked 69 Times in 46 Posts
Social Networking View Member's Myspace Profile  View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Yahoo to MagicAce
Default Re: PHP Mobile Detect/Redirect and View Full Site

This is what I use and it works very well:


On the dekstop website:


<?php
function is_mobile(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hos in|huawei|novarra|CoolPad|webos|techfaith|palmsour ce|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexi an|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|ma ui|";
$regex_match.="symbian|smartphone|midp|wap|phone|w indows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mob i|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
}

switch($_GET['mode'])
{
case 'mobile':
$mode = "mobile";
break;
case 'desktop':
$mode = "desktop";
break;
default:
$mode = is_mobile() ? "mobile" : "desktop";
break;
}

if ($mode == "mobile")
{
header ("Location: http://www.m.mainsite.com");
return;
}
?>

On the mobile website:

<a href="http://www.mainsite.com/?mode=desktop">Full Site</a>

MagicAce is offline   Reply With Quote
The Following 3 Users Say Thank You to MagicAce For This Useful Post:
Old 02-18-2013, 09:30 PM   #11
Active Warrior
War Room Member
 
noxid101's Avatar
 
Join Date: Feb 2010
Location: Berkeley, CA
Posts: 74
Blog Entries: 1
Thanks: 14
Thanked 26 Times in 22 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

I found the redirect script from Mobile Web Pro works well for this. But I have it set so only the home page is redirected so if you click "see full site" from your mobile device you can still visit the other pages without being redirected.

I created a duplicate home template called "homeR" and this makes it so only the home page redirects. The mobile site has a link that forces the home page to load.

PM me and I'll show you the details of how I do it.

Newbies PM me if you need simple answers to simple questions. Don't waste too much time figuring things out (being lost) when all you have to do is ask for directions. TweakingWP.com
noxid101 is offline   Reply With Quote
The Following User Says Thank You to noxid101 For This Useful Post:
Old 02-24-2013, 07:20 AM   #12
HyperActive Warrior
War Room Member
 
ASUService's Avatar
 
Join Date: Jul 2002
Location: USA.
Posts: 487
Thanks: 380
Thanked 125 Times in 98 Posts
Default Re: PHP Mobile Detect/Redirect and View Full Site

Quote:
Originally Posted by noxid101 View Post
I found the redirect script from Mobile Web Pro works well for this. But I have it set so only the home page is redirected so if you click "see full site" from your mobile device you can still visit the other pages without being redirected.

I created a duplicate home template called "homeR" and this makes it so only the home page redirects. The mobile site has a link that forces the home page to load.

PM me and I'll show you the details of how I do it.
I have to give a thumbs up for this method. This is what I've recommended to my clients for quite a while.

Best Regards,
Mike Allton
ASU Service, Inc.
The LAST SMS Platform You'll Ever Need! Easy Money!
ASUService is offline   Reply With Quote
Old 02-24-2013, 10:28 AM   #13
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default Re: PHP Mobile Detect/Redirect and View Full Site

Ok, I finally got it to work.

Here's the code:
<?php
@include("Mobile_Detect.php");
$detect = new Mobile_Detect();
if ($detect->isMobile() && isset($_COOKIE['mobile']))
{
$detect = "false";
}
elseif ($detect->isMobile())
{
header("Location:http://m.mobilesite.com");
}
setcookie("mobile","m", time()+3600, "/",".fullsite.com");
?>

I ended up combining the set cookie part which originally was in the index.php with the code that was put in my header.php

I put the combind code in my header.php and it is working great. I am also willing to bet that if I was to put that code in my index.php it would work too.

I appreciate all the help and suggestions.

Thanks!!!
EZE522 is offline   Reply With Quote
Old 03-07-2013, 09:37 AM   #14
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default Re: PHP Mobile Detect/Redirect and View Full Site

I should add that this is working with some code I added to the .htaccess
EZE522 is offline   Reply With Quote
Old 06-15-2013, 10:50 AM   #15
Warrior Member
 
Join Date: Jul 2007
Location: , , USA.
Posts: 20
Thanks: 8
Thanked 1 Time in 1 Post
Default Re: PHP Mobile Detect/Redirect and View Full Site

.htaccess code I added

RewriteEngine on
RewriteBase /

# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:www.fullsite.com]

RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iem obile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link )|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar (ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|b umb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a |jbro|jemu|jigs|kddi|keji|kgt(\ |\/)|klon|kpt\ |kwc\-|kyo(c|k)|le(no|xi)|lg(\ g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|d o|t(\-|\ |o|v)|zz)|mt(50|p1|v\ )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran |owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v\ )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(4 0|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98 )|w3c(\-|\ )|webc|whit|wi(g\ |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-) [NC]

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)

# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]

# Now redirect to the mobile site
RewriteRule ^ http://m.mobilewebsite.com [R,L]
EZE522 is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > The Warrior Forum > Mobile Marketing

Bookmarks

Tags
detect or redirect, full, mobile, php, site, view


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 12:24 PM.