www.webdeveloper.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36

Thread: After Mobile Redirect - View Full Site link

  1. #16
    Join Date
    Aug 2006
    Posts
    1,908
    I just checked on a mobile, and I see what you see. You must be doing this "IsMobile" check on every page for it to do that. I would only do the check on your home page. If you want make the mobile check on every page, you're going to have to save the users preference in a session variable so that once he decides you don't re-check on him all the time.

    Dave

  2. #17
    Join Date
    Apr 2011
    Posts
    14
    I guess you are right, the redirect code was in the index.php, instead of home.php of the main site. I changed it now and it seems to work just fine. No more redirects from main site to mobile once the visitor chooses to go to the main site from mobile site.

    I am checking using this tool:
    Code:
    http://code.google.com/p/ibbdemo2/
    I don't have a mobile phone with internet at the moment, I cannot check how it works on a real device now.

  3. #18
    Join Date
    Sep 2011
    Posts
    1
    I am new to .php coding - this thread has been very helpful.. but still a tad lost. So I put the code in the index.php & the index.html? or just the php..

    second nailener what do you mean the code was in index.php instead of home.php of the main site? do I need to build a page duplicate to the index and call it home..

    if you could help a newbie out and expand on what you mean?

    Please and thank you..

  4. #19
    Join Date
    Dec 2011
    Posts
    1

    What about home link

    I am just curious if you have looed into making the home link stay on the full site. On your site the home link will do the detection again and go to the mobile site.

  5. #20
    Join Date
    May 2012
    Posts
    1

    Simple Solution!

    Just discovered the easiest solution:
    Do nothing to the main site's index.php. In the mobile site, the code should look like:
    <a href="http://www.yourmainsite.com/index.html">View Full Site</a>

  6. #21
    Join Date
    May 2013
    Posts
    15

    Tracknut's redirect question

    I hope this post isn't to old to reply to.

    I'm testing Tracknut's sweet redirect PHP w/full site link on mobile. Its Exactly what I need, redirect each time, no cookie, Full site Query string URL.

    What's happening is, the execution stops in the PHP script and my web page is not continuing to load for desktop or mobile, something to do with the Breaks maybe? I'm not a php coder, but I use much php on the server side.

    When I view the Source on the blank page, all code is shown up to the php code below:
    Code:
    <!----------  Mobile Device Redirect function ------>
    <?php
    switch($_GET['mode'])
        {
    case 'mobile':
        $mode = "mobile";
        break;
    case 'desktop':
        $mode = "desktop";
        break;
    default:
        $mode = IsMobile() ? "mobile" : "desktop";
        break;
        }
    
    if ($mode == "mobile")
        {
        header ("Location: http://www.mobile.hepptech.com");
        return;
        }
    ?>
    Any suggestions appreciated.

  7. #22
    Join Date
    Aug 2006
    Posts
    1,908
    What's the value of $_GET['mode'] right before you enter the switch statement, and the value of $mode right after the close of the switch statement? Have you printed them out to see?

    Dave

  8. #23
    Join Date
    May 2013
    Posts
    15
    I'm not sure how to do this.

    Maybe you could suggest how I could see these values, maybe echo? I'll test echoing these values, maybe
    Code:
    Echo mode;
    ?

  9. #24
    Join Date
    May 2013
    Posts
    15
    Ok, I tried to add an echo, but with the echo (below code) there is a server error, not just a blank page.
    Code:
    <!----------  Mobile Device Redirect function ------>
    <?php
    switch($_GET['mode'])
        {
    echo("Mode= mode");  //also tested:  echo  mode;
    case 'mobile':
        $mode = "mobile";
        break;

  10. #25
    Join Date
    Aug 2006
    Posts
    1,908
    Use:
    echo "mode=".$_GET('mode');

    and at the bottom:
    echo "mode=".$mode;

    Dave

  11. #26
    Join Date
    May 2013
    Posts
    15
    Nothing is displaying after my <!---------- Mobile Device Redirect function ------> that is above your php.

    When viewing the page source, no code whatsoever is displayed after the above bar, no echoed values.

    I'm thinking this or any php method is not usable in an html page.

  12. #27
    Join Date
    Aug 2006
    Posts
    1,908
    Quote Originally Posted by Antonia View Post
    I'm thinking this or any php method is not usable in an html page.
    Yes, that's correct. You need to have this file renamed as something.php, and you need php running on your server.

    Dave

  13. #28
    Join Date
    May 2013
    Posts
    15
    I have php on the server, all of my server scripts operate. A tech support guy at the web host co added a line of code to the .htaccesss file (AddHandler application/x-httpd-php .html .htm) to supposedly enable php script on my pages. I renamed my page index.php to test, it loads in the oroginal state, but the redirector code still stops the page from loading. I must have a lot to learn.

    I appreciate you time Dave. thanks

  14. #29
    Join Date
    May 2013
    Posts
    15
    (Dave, I'm taking code off & on this all eve, its not working)

    I have learned that any PHP redirect needs to to be the first item on the page, ahead of any HTML tag. Helpful article here-> http://php.about.com/od/learnphp/ht/phpredirection.htm

    I tested this code, it worked perfect:
    Code:
    <?php
       header( 'Location: http://www.yoursite.com/new_page.html' ) ;
    ?>
    But using this code from this post, I get a Server Error:
    Code:
    <?php
    switch($_GET['mode'])
        {
    case 'mobile':
        $mode = "mobile";
        break;
    case 'desktop':
        $mode = "desktop";
        break;
    default:
        $mode = IsMobile() ? "mobile" : "desktop";
        break;
        }
    
    if ($mode == "mobile")
        {
        header ("Location: http://www.mobile.hepptech.com");
        return;
        }
    ?>
    Could something be missing from this code?

    I'm sure now, I can make a php redirector work on my HTML page.

  15. #30
    Join Date
    May 2013
    Posts
    15
    Its working !!! I'm using this php at the top of my html page, before anything else:
    Code:
    <?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;
    }
    ?>
    This in my Full Site link URL:
    Code:
    <a href="http://www.mainsite.com/?mode=desktop">Full Site</a>
    The secret Magic was placing the redirect on the html page, Before Anything Else.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles