RSS Feed

More php / mySQL | html | css | js

     Notes: PHP / MYSQL | HTML | CSS | JS
free-php-scripts
free-joomla-extensions

Jan 24
2011

Browser Redirects

Posted by bohemia in Untagged 

Using PHP to redirect pages based on browser can make life simpler in some circumstances. The following samples below show various redirects for various browers.

if(preg_match("/opera/i",$_SERVER['HTTP_USER_AGENT']))
die(header("Location: http://getfirefox.com"));
?>
 
<?php
if(preg_match("/chrome/i",$_SERVER['HTTP_USER_AGENT']))
die(header("Location: http://getfirefox.com"));
?>
 
<?php
if(preg_match("/safari/i",$_SERVER['HTTP_USER_AGENT']))
die(header("Location: http://getfirefox.com"));
?>
 
<?php
if(preg_match("/MSIE/i",$_SERVER['HTTP_USER_AGENT']))
die(header("Location: http://getfirefox.com"));
?>
 
<?
$redirect="http://www.redirecturlputhere.net";
if(preg_match('/Firefox/',$_SERVER['HTTP_USER_AGENT']))!
=1) header("Location: ".$redirect);
?>

Comments (0)add comment

Write comment

busy