Page 1 of 1

Creating a custom browser redirection script

Posted: Wed Jun 19, 2002 3:40 pm
by pup100
New to PHP new to programming. Have bought a brief introduction to the subject & have been fascinated & impressed by the possibilities & versatility of the code.

My problem.

Having been choughed by some early experiments in using getenv & preg_match functions to identify a browser, how would I be able to automatically redirect a browser to the corresponding browser page?

I have set out below my most recent attempt, which no doubt is most lamentable but if anyone could “hold my hand” on this one & explain basically where I’m going wrong I would most appreciate it.

<?

$agent = getenv("HTTP_USER_AGENT");

if (preg_match("/MSIE/i", "$agent")) {
header ("Location: = http://www.My IE6 site");
exit;
}

?>


Thank you very much for any assistance

JD
(London)

Posted: Wed Jun 19, 2002 4:36 pm
by volka
are you sure it's set in the enviroment?
Try instead $_SERVER['HTTP_USER_AGENT'] (or $HTTP_SERVER_VARS php.version < 4.1.0) and have a look at get_browser

Posted: Wed Jun 19, 2002 5:40 pm
by Zmodem
I don't believe there is an = sign in the header statement. Try removing it.

Also, make sure you aren't sending anything to the browser before you call header();

Thank you

Posted: Thu Jun 20, 2002 5:27 pm
by pup100
thank you very much for the input. I will try these options out.

Cheers chaps.

JD