Monj87 Posted August 14, 2011 Share Posted August 14, 2011 I know i suck at php but i need help lol. I just started working at this medical company in encinitas and one of their sites is really janky so in a few browsers like older IE and firefox you can't even navigate through the site. I dont have time to spend on fixing it now so i wanted to use something like this. do you know how to make a conditional like this but make it say If the user is in firefox 2 it will redirect them to a seperate location. I already have conditional style sheets setup but the firefox 2 issues are beyond styling because it is a massive shopping cart and its not shoppable on firefox 2 so I will send them to my older site that works correctly on firefox 2 I need to start studying more php lol. <?php $referer = $_SERVER['HTTP_REFERER']; $domain_name = "somedomain.com"; if(strpos($referer, $domain_name)!== FALSE) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.yourdomain.com/newpage.php"); exit; } ?> Thank you!! Quote Link to comment Share on other sites More sharing options...
xyph Posted August 14, 2011 Share Posted August 14, 2011 Use $_SERVER['HTTP_USER_AGENT'] That's not guaranteed to hold a real value though. Quote Link to comment Share on other sites More sharing options...
Monj87 Posted August 14, 2011 Author Share Posted August 14, 2011 would you be able to tell me how to use 'HTTP_USER_AGENT' in this code to make somedomain.com/about-us.htm redirect to somedomain2.com/about-us.htm if the user is on firefox 2 browser? <?php $referer = $_SERVER['HTTP_REFERER']; $domain_name = "somedomain.com"; if(strpos($referer, $domain_name)!== FALSE) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.yourdomain.com/newpage.php"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
xyph Posted August 14, 2011 Share Posted August 14, 2011 No. I help people with PHP. I don't code for free. At least make an attempt. Jeez. Quote Link to comment Share on other sites More sharing options...
Clarkeez Posted August 14, 2011 Share Posted August 14, 2011 http://php.net/manual/en/reserved.variables.server.php Maybe you can use $_SESSION['HTTP_USER_AGENT'] like xyph said and then use str_replace or preg_replace to pull it apart. You'll need to test that variable using different browsers so you can relate the output to different browsers as accurately as you can. Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted August 14, 2011 Share Posted August 14, 2011 if this helps you <?php $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; function str_present($str,$substr) { $pos = strpos($str,$substr); if($pos === false) { return false; } else { return true; } } if (str_present($HTTP_USER_AGENT, "Opera/9.27")) { header('location: url1'); }else{ header('location: url2'); } ?> Quote Link to comment Share on other sites More sharing options...
xyph Posted August 14, 2011 Share Posted August 14, 2011 How is if (str_present($HTTP_USER_AGENT, "Opera/9.27")) different than if (strpos($HTTP_USER_AGENT, "Opera/9.27") !== FALSE ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.