Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

Browser redirect

Code Wizard, 12-30-2006

Simple script that gets the browser type from the http_user_agent and redirects to a page accordingly. I guess you could change the "redirect" to something else...maybe load in a different stylesheet for each browser...

<?php
// Redirect to: (must have trailing slash)

$redirect_uri = "http://www.your-domain.co.uk/";

// Page extension: (.htm .html .php .shtml etc)
$extension = ".php";

// start:
if ($name = strstr ($HTTP_USER_AGENT, "Opera")) {
$browser = "opera";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "MSIE")) {
$browser = "ie";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "WebTV")) {
$browser = "webtv";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "Mozilla/4")) {
$browser = "nn4";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "Mozilla/5")) {
$browser = "nn6";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "Lynx")) {
$browser = "lynx";
}
elseif ($name = strstr ($HTTP_USER_AGENT, "w3m")) {
$browser = "w3m";
}
else { $browser = "unknown";
}

// redirect location
Header ("Location: $redirect_uri"."$browser"."$extension");
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions