Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Adding phones to a mobile redirect?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #28425
    JoblessPunk
    Member

    Hello,
    I’m working on a mobile redirect for my website I’m building. I found this really nice PHP mobile redirect code and it works, mostly. I just did some field testing and it seems to only redirect on half of the phones I tested.

    Here are the phones that did not redirect:
    T-Mobile – MyTouch
    G1
    Sidekick (all)
    Motorola DROID
    Pixie (all)
    Garmin
    Sprint Interpid
    HTC Snap
    HTC Touch Pro

    Here is the PHP:

    Code:
    0) or ((isset($_SERVER[‘HTTP_X_WAP_PROFILE’]) or isset($_SERVER[‘HTTP_PROFILE’])))) {
    $mobile_browser++;
    }

    $mobile_ua = strtolower(substr($_SERVER[‘HTTP_USER_AGENT’],0,4));
    $mobile_agents = array(
    ‘w3c ‘,’acs-‘,’alav’,’alca’,’amoi’,’audi’,’avan’,’benq’,’bird’,’blac’,
    ‘blaz’,’brew’,’cell’,’cldc’,’cmd-‘,’dang’,’doco’,’eric’,’hipt’,’inno’,
    ‘ipaq’,’java’,’jigs’,’kddi’,’keji’,’leno’,’lg-c’,’lg-d’,’lg-g’,’lge-‘,
    ‘maui’,’maxo’,’midp’,’mits’,’mmef’,’mobi’,’mot-‘,’moto’,’mwbp’,’nec-‘,
    ‘newt’,’noki’,’oper’,’palm’,’pana’,’pant’,’phil’,’play’,’port’,’prox’,
    ‘qwap’,’sage’,’sams’,’sany’,’sch-‘,’sec-‘,’send’,’seri’,’sgh-‘,’shar’,
    ‘sie-‘,’siem’,’smal’,’smar’,’sony’,’sph-‘,’symb’,’t-mo’,’teli’,’tim-‘,
    ‘tosh’,’tsm-‘,’upg1′,’upsi’,’vk-v’,’voda’,’wap-‘,’wapa’,’wapi’,’wapp’,
    ‘wapr’,’webc’,’winw’,’winw’,’xda’,’xda-‘);

    if(in_array($mobile_ua,$mobile_agents)) {
    $mobile_browser++;
    }

    if (strpos(strtolower($_SERVER[‘ALL_HTTP’]),’OperaMini’)>0) {
    $mobile_browser++;
    }

    if (strpos(strtolower($_SERVER[‘HTTP_USER_AGENT’]),’windows’)>0) {
    $mobile_browser=0;
    }

    else {
    if($mobile_browser>0) {
    header(“Location: http://m.joblesspunkdesigns.com”); /* Redirect browser */
    exit; /* Make sure that code below does not get executed after redirect. */
    }
    }

    ?>

    Is there a way to add these phones to the list to redirect them to the mobile site?

    Thank you,
    tim

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.