Url Redirection Based on Operating System?

Discussion in 'Cloaking and Content Generators' started by jutt29, Dec 10, 2011.

  1. jutt29

    jutt29 Regular Member

    Joined:
    Sep 10, 2010
    Messages:
    321
    Likes Received:
    65
    Occupation:
    Student
    Location:
    Internet!
    Can Some please give me the script to redirect my MAC and Windows user to different Urls?
    Thanks
     
  2. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,046
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    Code:
    <?php
    
    $windows_url = 'http://www.microsoft.com/';
    $mac_url     = 'http://www.apple.com/';
    $other_url   = 'http://www.lemonparty.org/';
    
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    
    if(preg_match('/microsoft|window/i', $user_agent)) {
    	header("Location: $windows_url", true, 301);
    } elseif(preg_match('/mac|os x/i', $user_agent)) {
    	header("Location: $mac_url", true, 301);
    } else {
    	header("Location: $other_url", true, 301);
    }
    
    ?>
    
    Pretty self explanatory really. Fill in your urls up the top and include it before the opening <head> tag on your page.
     
    • Thanks Thanks x 2
  3. paulcarter97

    paulcarter97 Regular Member

    Joined:
    Nov 27, 2011
    Messages:
    391
    Likes Received:
    37
    Nice script, quick question. Why would you want this kind of redirrect ?
     
  4. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,046
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    Probably so you can show ads that are targeted to each operating system, eg. show Windows users some anti-virus shit and Mac users some other crapware like MacKeeper. You wouldn't necessarily have to redirect - you could just identify the user agent as belonging to a particular OS and then just show an ad for that platform in your normal page.