Mobile redirect script please

Discussion in 'Mobile Marketing' started by elviswong, Oct 4, 2012.

  1. elviswong

    elviswong Senior Member Premium Member

    Joined:
    Nov 8, 2011
    Messages:
    958
    Likes Received:
    256
    Occupation:
    Making money online since 91
    Location:
    In front of my PC
    Guys
    I'm looking for a redirect script or something that can redirect mobile traffic going to my "PC/Laptop" created web sites.
    No need to show them this content. Worthless...

    Something that detects if it's a mobile, then redirects depending of the country of origin, to the site/offer (whatever i wish) that fits.

    Ex:

    Guy from USA passes by one of my site using an Iphone, scripts knows he's using a mobile, sends him to a UsaMobileUser.mysite.com instead of www.mysite.com.
    On this, offer/or anything that fits an American using a mobile.

    CanadianMobileUser.mysite.com
    UkMobileUser.mysite.com

    and so on and so on..

    THANKS
     
  2. Olbol123

    Olbol123 Newbie

    Joined:
    Aug 28, 2012
    Messages:
    16
    Likes Received:
    2
    This can be done loads of different ways, have a look at this site and implement the code that is best suited for your site. detectmobilebrowsers(.)c0m/
     
  3. sirgold

    sirgold BANNED BANNED

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    647
    You can simply do it by redirecting based on the useragent. Check the first answer here: http://stackoverflow.com/questions/9624644/php-redirect-to-mobile-version-if-user-browses-to-subdomain
     
    • Thanks Thanks x 1
  4. a63i89a

    a63i89a BANNED BANNED

    Joined:
    Apr 30, 2012
    Messages:
    106
    Likes Received:
    9
    Simple code..? Take mine...

     
    • Thanks Thanks x 1
    Last edited: Oct 4, 2012
  5. valind

    valind Newbie

    Joined:
    Nov 25, 2011
    Messages:
    23
    Likes Received:
    3
    Location:
    Behind a computer
    Redirect through .htaccess:

    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} de.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-ch.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} at.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} en-gb.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-at.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-li.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} fr-ch.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} ch.* [NC,OR]
    RewriteCond %{HTTP_ACCEPT_LANGUAGE} de-de.* [NC,OR]
    RewriteRule .* НТТР://dомаin.сом [R,L]

    Redirect through JavaScript:

    <script language="JavaScript">
    var language1, language2, i, f;
    var loc = new Array("at","au","be","ca","dk","es","fi","gr","ch","de-ch","de","fr","en-ie","ie","en-gb","nl","it","gb","no","pt","nz","us");
    if (navigator.appName.indexOf("Microsoft") != -1) {
    language1=navigator.systemLanguage.toLowerCase();
    language2=navigator.userLanguage.toLowerCase();
    } else { language1=language2=navigator.language.toLowerCase(); }
    for (f=false,i=0;i || (language2 == loc)) { f = true; break; } }
    if (f) document.location="НТТР://dомаin.сом";
    </script>

    All specified users (registered) zones will be redirected, not indicated-to remain on the page.
    See more: munkyonline(DОТ)co(DОТ)uk/articles/htaccess-301-redirects-for-ip-ranges
     
  6. a63i89a

    a63i89a BANNED BANNED

    Joined:
    Apr 30, 2012
    Messages:
    106
    Likes Received:
    9
    That's code for Language detection not Mobile Browser Agent detection :'|
     
  7. mazar

    mazar Regular Member

    Joined:
    May 24, 2010
    Messages:
    354
    Likes Received:
    133
    copy and paste just above your homepage </head> tag. replace yourwebsite.com with your own. If you've changed the name of the 'mobile' folder, make the changes below .
    <--




    <script type="text/javascript">
    if(screen.width < 600){
    window.location = "http://yoursite/mobile/index.html";
    }
    </script>

    </head>
    <body>
     
    • Thanks Thanks x 1
  8. timmy79

    timmy79 Regular Member

    Joined:
    Aug 18, 2012
    Messages:
    429
    Likes Received:
    124
    here is the .htaccess redirect that I use:
    webdesignandsuch[dot]com/redirect-to-a-mobile-site-with-htaccess-and-set-a-cookie-to-break-redirect/

    So far this is the best one I found
     
  9. dudemike

    dudemike Power Member

    Joined:
    Jan 20, 2009
    Messages:
    559
    Likes Received:
    94
    with new samsung s3 phones i had to change value from 600 to 800

     
  10. skulquake

    skulquake Registered Member

    Joined:
    Oct 6, 2010
    Messages:
    77
    Likes Received:
    10
    These are great responses thx guys