php mutliple browser use agent redirection script
buzz
Status: New User - Welcome
Joined: 03 Jan 2009
Posts: 1
Reply Quote
Hello,
Can some one tell me what I am doing wrong here;


<?
// Browser Based Redirection

// If browser is Internet Explorer
if ($name = strstr ($HTTP_USER_AGENT, "MSIE")) {Header ("Location: www.microsoft.com/");}
// If browser is Mozilla
elseif ($name = strstr ($HTTP_USER_AGENT, "Mozilla")) {Header ("Location: www.firefox.com/");}
// If browser is anything else
else { Header ("Location: www.google.com/");}
?>

I want to set up a multi-browser redirection script based on browsers user agent.

And if anyone also knows how I can achieve the same result using a htaccess file on apache 2.0 server

I hope someone can help.

buzz
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3788
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
:: Code ::
$name = strstr ($HTTP_USER_AGENT, "MSIE"))


Make sure you read about how to use php before you try to do it, if you don't know the syntax it's essentially impossible to do programming in any language, so it pays to either buy a basic book on it (o'reilly books are great) or to read some good basic tutorials online, making sure you understand each and every character and syntax operator in the samples.

= is an assignment operator, and == and === are equality operators.

Also make sure to check out our various php browser and language detection scripts for more examples. I suggest the simple php browser detection and the language detection to see working samples.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours