Jump to content

PHP URL Redirect Help


Monj87

Recommended Posts

:wtf: 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!! :P

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.