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!! Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/ 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. Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257370 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; } ?> Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257401 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. Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257405 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. Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257413 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'); } ?> Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257414 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 ) Link to comment https://forums.phpfreaks.com/topic/244785-php-url-redirect-help/#findComment-1257420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.