Honesty Rocks! truth rules.

Redirect If Not Using Firefox

HOME      >>       Programming

kobra500

Basically i want a code to redirect people to a different page if they're using anything but firefox, there are codes for it but i cant find 1. If anyone can give me a hand it would be appreciated!!!


galexcd

You could do this in javascript, but then nothing would happen to people with javascript disabled. I believe the best solution for this is to use some php.

$redirect="http://redirecturlgoeshere.net;;if(preg_match('/Firefox/',$_SERVER['HTTP_USER_AGENT']))!=1) header("Location: ".$redirect);

But if the reason you want to do this is because IE or some other browser isn't supported you might want to think about allowing safari as well seeing as they render pages almost exactly alike.

kobra500

Yeah bu safari is an apple program ^_^ ... i dont want their kind visiting my site : D
teasing! - (quoted cos i dont deserve credits 4 it)


do i just replace the firefox bit with safari??

galexcd

If you want to include safari do this:

$redirect="http://redirecturlgoeshere.net;;if(preg_match(array('/Firefox/','/Safari/'),$_SERVER['HTTP_USER_AGENT']))!=1) header("Location: ".$redirect);


gameratheart

Thanks for the script, galexcd! If not anyone else, I know I will find it useful! Your script will mean I can continue to make the quality websites Firefox and Safari are good for, without worrying about whether inferior browsers such as IE will break them. I can just redirect them to a less standards-complaint page and job done!