PHP Redirection Problem
Posted: Tue Jan 27, 2009 11:29 pm
I'm not an experienced php coder, I just understand basic html. I'm working on a script I found and it's supposed to redirect you to a different website if you come from a specific link or have a referer. If for example: you type in the url to WEBSITEA.COM into the web browser directly there wouldn't be a referer so you would see the content of WEBSITEA.COM and you would not be redirected. If there is a referer, example: you came from a link on another website (http://xxxxxx.com/link.php) then insted of seeing WEBSITEA.COM you will be redirected to another website (WEBSITEB.COM) and you will not see WEBSITEA.COM.
The problem is that the php code on WEBSITEA.COM is not redirecting to WEBSITEB.COM even if there is a referer. I tested by creating a test.html page in a different folder. I checked the headers by using a FF plug-in called, "Tamper Data". When it gets to WEBSITEA.COM where it's supposed to redirect in "Temper Data" it says the referer is /Test/Test.htm so there is a referer. Although it's not redirecting to WEBSITEB.COM
Here's the code:
I put in the html tags since this is where the content of WEBSITEA.COM starts if you come to the website with no referer.
I think the problem is with the referer. Since in the above code it's redirecting based on the referer which it's specifying as: http://xxxxxx/link.php. However what I noticed by using, "Tamper Data" is that, the referer is being logged as the site that the link to link.php is placed on. So, if I place a link to http://xxxxx/link.php on Test/Test.htm it's going to specify the referer is Test/Test.htm not http://xxxxx/link.php as in the code above.
I tried modifying the code for testing purposes and changing the server referer line to /Test/Test.htm since this is what it is in "Tamper Data" and it still didn't work.
If I type in the url of WEBSITEA.COM directly into the address bar, I do end up getting the content of WEBSITEA.com so this part is working. It's just not redirecting to WEBSITEB.com if you come through a referer.
If it makes any difference, http://xxxxxx.com/link.php which links to WEBSITEA.COM is always going to be the same link, http://xxxxxx.com/link.php. This link.php is important in determining where the user is redirected. It doesn't matter to me what the referer is since the actual website that links to http://xxxxx.com/link.php will change.
I've been searching for google and trying to set this up for several hours!
Any help would be appreciated,
Thanks!
The problem is that the php code on WEBSITEA.COM is not redirecting to WEBSITEB.COM even if there is a referer. I tested by creating a test.html page in a different folder. I checked the headers by using a FF plug-in called, "Tamper Data". When it gets to WEBSITEA.COM where it's supposed to redirect in "Temper Data" it says the referer is /Test/Test.htm so there is a referer. Although it's not redirecting to WEBSITEB.COM
Here's the code:
Code: Select all
<?php
if ( $_SERVER['HTTP_REFERER'] == "http://xxxxxx.com/link.php" ) {
Header ("Location: http://WEBSITE-B.COM"); exit(0);
} else {
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>I put in the html tags since this is where the content of WEBSITEA.COM starts if you come to the website with no referer.
I think the problem is with the referer. Since in the above code it's redirecting based on the referer which it's specifying as: http://xxxxxx/link.php. However what I noticed by using, "Tamper Data" is that, the referer is being logged as the site that the link to link.php is placed on. So, if I place a link to http://xxxxx/link.php on Test/Test.htm it's going to specify the referer is Test/Test.htm not http://xxxxx/link.php as in the code above.
I tried modifying the code for testing purposes and changing the server referer line to /Test/Test.htm since this is what it is in "Tamper Data" and it still didn't work.
If I type in the url of WEBSITEA.COM directly into the address bar, I do end up getting the content of WEBSITEA.com so this part is working. It's just not redirecting to WEBSITEB.com if you come through a referer.
If it makes any difference, http://xxxxxx.com/link.php which links to WEBSITEA.COM is always going to be the same link, http://xxxxxx.com/link.php. This link.php is important in determining where the user is redirected. It doesn't matter to me what the referer is since the actual website that links to http://xxxxx.com/link.php will change.
I've been searching for google and trying to set this up for several hours!
Any help would be appreciated,
Thanks!