Can Some please give me the script to redirect my MAC and Windows user to different Urls?
Thanks
Can Some please give me the script to redirect my MAC and Windows user to different Urls?
Thanks
Pretty self explanatory really. Fill in your urls up the top and include it before the opening <head> tag on your page.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); } ?>
"An ounce of action is worth a ton of theory." - Ralph Waldo Emerson
jutt29 (12-17-2011), paulcarter97 (12-17-2011)
Nice script, quick question. Why would you want this kind of redirrect ?
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.
"An ounce of action is worth a ton of theory." - Ralph Waldo Emerson
Bookmarks